fix(RHI): 修复 OpenGL/D3D12 后端编译问题

- 修复 OpenGLCommandList 方法签名匹配 RHI 抽象接口
- 修复 OpenGLSwapChain Present/Resize 方法签名
- 添加 OpenGL 特有方法重载支持后端测试(底层逃逸)
- 暂时禁用不兼容的 Resources 模块
- 更新 OpenGL 测试 CMakeLists
This commit is contained in:
2026-03-17 19:35:51 +08:00
parent a257ff2d8b
commit e138fb2075
15 changed files with 188 additions and 308 deletions

View File

@@ -41,9 +41,7 @@ void D3D12CommandList::Shutdown() {
m_trackedResources.clear();
}
void D3D12CommandList::Reset(ID3D12CommandAllocator* allocator) {
m_commandList->Reset(allocator, nullptr);
void D3D12CommandList::Reset() {
m_currentTopology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
m_currentPipelineState = nullptr;
m_currentRootSignature = nullptr;
@@ -54,7 +52,23 @@ void D3D12CommandList::Close() {
m_commandList->Close();
}
void D3D12CommandList::TransitionBarrier(ID3D12Resource* resource, ResourceStates stateBefore, ResourceStates stateAfter, uint32_t subresource) {
void D3D12CommandList::TransitionBarrier(void* resource, ResourceStates stateBefore, ResourceStates stateAfter) {
TransitionBarrierInternal(static_cast<ID3D12Resource*>(resource), stateBefore, stateAfter);
}
void D3D12CommandList::UAVBarrier(void* resource) {
UAVBarrierInternal(static_cast<ID3D12Resource*>(resource));
}
void D3D12CommandList::AliasBarrier(void* beforeResource, void* afterResource) {
AliasBarrierInternal(static_cast<ID3D12Resource*>(beforeResource), static_cast<ID3D12Resource*>(afterResource));
}
void D3D12CommandList::SetPipelineState(void* pso) {
SetPipelineStateInternal(static_cast<ID3D12PipelineState*>(pso));
}
void D3D12CommandList::TransitionBarrierInternal(ID3D12Resource* resource, ResourceStates stateBefore, ResourceStates stateAfter, uint32_t subresource) {
D3D12_RESOURCE_BARRIER barrier = {};
barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
barrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
@@ -68,7 +82,7 @@ void D3D12CommandList::TransitionBarrier(ID3D12Resource* resource, ResourceState
m_resourceStateMap[resource] = stateAfter;
}
void D3D12CommandList::UAVBarrier(ID3D12Resource* resource) {
void D3D12CommandList::UAVBarrierInternal(ID3D12Resource* resource) {
D3D12_RESOURCE_BARRIER barrier = {};
barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_UAV;
barrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
@@ -77,7 +91,7 @@ void D3D12CommandList::UAVBarrier(ID3D12Resource* resource) {
m_commandList->ResourceBarrier(1, &barrier);
}
void D3D12CommandList::AliasBarrier(ID3D12Resource* beforeResource, ID3D12Resource* afterResource) {
void D3D12CommandList::AliasBarrierInternal(ID3D12Resource* beforeResource, ID3D12Resource* afterResource) {
D3D12_RESOURCE_BARRIER barrier = {};
barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_ALIASING;
barrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
@@ -87,16 +101,11 @@ void D3D12CommandList::AliasBarrier(ID3D12Resource* beforeResource, ID3D12Resour
m_commandList->ResourceBarrier(1, &barrier);
}
void D3D12CommandList::SetPipelineState(ID3D12PipelineState* pso) {
void D3D12CommandList::SetPipelineStateInternal(ID3D12PipelineState* pso) {
m_commandList->SetPipelineState(pso);
m_currentPipelineState = pso;
}
void D3D12CommandList::SetRootSignature(ID3D12RootSignature* signature) {
m_commandList->SetGraphicsRootSignature(signature);
m_currentRootSignature = signature;
}
void D3D12CommandList::SetViewport(const Viewport& viewport) {
D3D12_VIEWPORT d3d12Viewport = {};
d3d12Viewport.TopLeftX = viewport.topLeftX;
@@ -150,7 +159,15 @@ void D3D12CommandList::SetPrimitiveTopology(PrimitiveTopology topology) {
m_currentTopology = ToD3D12Topology(topology);
}
void D3D12CommandList::SetRenderTargets(uint32_t count, ID3D12Resource** renderTargets, ID3D12Resource* depthStencil) {
void D3D12CommandList::SetRenderTargets(uint32_t count, void** renderTargets, void* depthStencil) {
std::vector<ID3D12Resource*> resources(count);
for (uint32_t i = 0; i < count; ++i) {
resources[i] = static_cast<ID3D12Resource*>(renderTargets[i]);
}
SetRenderTargetsInternal(count, resources.data(), static_cast<ID3D12Resource*>(depthStencil));
}
void D3D12CommandList::SetRenderTargetsInternal(uint32_t count, ID3D12Resource** renderTargets, ID3D12Resource* depthStencil) {
std::vector<D3D12_CPU_DESCRIPTOR_HANDLE> rtvHandles(count);
for (uint32_t i = 0; i < count; ++i) {
rtvHandles[i].ptr = 0;
@@ -162,11 +179,11 @@ void D3D12CommandList::SetRenderTargets(uint32_t count, ID3D12Resource** renderT
m_commandList->OMSetRenderTargets(count, count > 0 ? rtvHandles.data() : nullptr, FALSE, depthStencil ? &dsvHandle : nullptr);
}
void D3D12CommandList::SetRenderTargets(uint32_t count, const D3D12_CPU_DESCRIPTOR_HANDLE* renderTargetHandles, const D3D12_CPU_DESCRIPTOR_HANDLE* depthStencilHandle) {
m_commandList->OMSetRenderTargets(count, renderTargetHandles, FALSE, depthStencilHandle);
void D3D12CommandList::SetVertexBuffer(uint32_t slot, void* buffer, uint64_t offset, uint32_t stride) {
SetVertexBufferInternal(slot, static_cast<ID3D12Resource*>(buffer), offset, stride);
}
void D3D12CommandList::SetVertexBuffer(uint32_t slot, ID3D12Resource* buffer, uint64_t offset, uint32_t stride) {
void D3D12CommandList::SetVertexBufferInternal(uint32_t slot, ID3D12Resource* buffer, uint64_t offset, uint32_t stride) {
D3D12_VERTEX_BUFFER_VIEW view = {};
view.BufferLocation = buffer->GetGPUVirtualAddress() + offset;
view.SizeInBytes = static_cast<UINT>(buffer->GetDesc().Width) - static_cast<UINT>(offset);
@@ -175,11 +192,25 @@ void D3D12CommandList::SetVertexBuffer(uint32_t slot, ID3D12Resource* buffer, ui
m_commandList->IASetVertexBuffers(slot, 1, &view);
}
void D3D12CommandList::SetVertexBuffers(uint32_t startSlot, uint32_t count, const D3D12_VERTEX_BUFFER_VIEW* views) {
void D3D12CommandList::SetVertexBuffers(uint32_t startSlot, uint32_t count, const uint64_t* buffers, const uint64_t* offsets, const uint32_t* strides) {
std::vector<D3D12_VERTEX_BUFFER_VIEW> views(count);
for (uint32_t i = 0; i < count; ++i) {
views[i].BufferLocation = buffers[i];
views[i].StrideInBytes = strides[i];
views[i].SizeInBytes = 0;
}
SetVertexBuffersInternal(startSlot, count, views.data());
}
void D3D12CommandList::SetVertexBuffersInternal(uint32_t startSlot, uint32_t count, const D3D12_VERTEX_BUFFER_VIEW* views) {
m_commandList->IASetVertexBuffers(startSlot, count, views);
}
void D3D12CommandList::SetIndexBuffer(ID3D12Resource* buffer, uint64_t offset, Format indexFormat) {
void D3D12CommandList::SetIndexBuffer(void* buffer, uint64_t offset, Format format) {
SetIndexBufferInternal(static_cast<ID3D12Resource*>(buffer), offset, format);
}
void D3D12CommandList::SetIndexBufferInternal(ID3D12Resource* buffer, uint64_t offset, Format indexFormat) {
D3D12_INDEX_BUFFER_VIEW view = {};
view.BufferLocation = buffer->GetGPUVirtualAddress() + offset;
view.SizeInBytes = static_cast<UINT>(buffer->GetDesc().Width) - static_cast<UINT>(offset);
@@ -240,11 +271,19 @@ void D3D12CommandList::DrawIndexed(uint32_t indexCount, uint32_t instanceCount,
m_commandList->DrawIndexedInstanced(indexCount, instanceCount, startIndex, baseVertex, startInstance);
}
void D3D12CommandList::DrawInstancedIndirect(ID3D12Resource* argBuffer, uint64_t alignedByteOffset) {
void D3D12CommandList::DrawInstancedIndirect(void* argBuffer, uint64_t alignedByteOffset) {
DrawInstancedIndirectInternal(static_cast<ID3D12Resource*>(argBuffer), alignedByteOffset);
}
void D3D12CommandList::DrawIndexedInstancedIndirect(void* argBuffer, uint64_t alignedByteOffset) {
DrawIndexedInstancedIndirectInternal(static_cast<ID3D12Resource*>(argBuffer), alignedByteOffset);
}
void D3D12CommandList::DrawInstancedIndirectInternal(ID3D12Resource* argBuffer, uint64_t alignedByteOffset) {
m_commandList->ExecuteIndirect(nullptr, 1, argBuffer, alignedByteOffset, nullptr, 0);
}
void D3D12CommandList::DrawIndexedInstancedIndirect(ID3D12Resource* argBuffer, uint64_t alignedByteOffset) {
void D3D12CommandList::DrawIndexedInstancedIndirectInternal(ID3D12Resource* argBuffer, uint64_t alignedByteOffset) {
m_commandList->ExecuteIndirect(nullptr, 1, argBuffer, alignedByteOffset, nullptr, 0);
}
@@ -270,7 +309,11 @@ void D3D12CommandList::ClearUnorderedAccessView(D3D12_GPU_DESCRIPTOR_HANDLE view
m_commandList->ClearUnorderedAccessViewFloat(viewHandle, resourceHandle, unorderedAccess, values, rectCount, rects);
}
void D3D12CommandList::CopyResource(ID3D12Resource* dst, ID3D12Resource* src) {
void D3D12CommandList::CopyResource(void* dst, void* src) {
CopyResourceInternal(static_cast<ID3D12Resource*>(dst), static_cast<ID3D12Resource*>(src));
}
void D3D12CommandList::CopyResourceInternal(ID3D12Resource* dst, ID3D12Resource* src) {
m_commandList->CopyResource(dst, src);
}
@@ -318,7 +361,11 @@ void D3D12CommandList::Dispatch(uint32_t threadGroupCountX, uint32_t threadGroup
m_commandList->Dispatch(threadGroupCountX, threadGroupCountY, threadGroupCountZ);
}
void D3D12CommandList::DispatchIndirect(ID3D12Resource* argBuffer, uint64_t alignedByteOffset) {
void D3D12CommandList::DispatchIndirect(void* argBuffer, uint64_t alignedByteOffset) {
DispatchIndirectInternal(static_cast<ID3D12Resource*>(argBuffer), alignedByteOffset);
}
void D3D12CommandList::DispatchIndirectInternal(ID3D12Resource* argBuffer, uint64_t alignedByteOffset) {
m_commandList->ExecuteIndirect(nullptr, 1, argBuffer, alignedByteOffset, nullptr, 0);
}
@@ -343,191 +390,5 @@ void D3D12CommandList::TrackResource(ID3D12Resource* resource) {
}
}
void D3D12CommandList::Reset() {
m_currentTopology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
m_currentPipelineState = nullptr;
m_currentRootSignature = nullptr;
m_currentDescriptorHeap = nullptr;
}
void D3D12CommandList::TransitionBarrier(void* resource, ResourceStates stateBefore, ResourceStates stateAfter) {
TransitionBarrierInternal(static_cast<ID3D12Resource*>(resource), stateBefore, stateAfter);
}
void D3D12CommandList::UAVBarrier(void* resource) {
UAVBarrierInternal(static_cast<ID3D12Resource*>(resource));
}
void D3D12CommandList::AliasBarrier(void* beforeResource, void* afterResource) {
AliasBarrierInternal(static_cast<ID3D12Resource*>(beforeResource), static_cast<ID3D12Resource*>(afterResource));
}
void D3D12CommandList::SetPipelineState(void* pso) {
SetPipelineStateInternal(static_cast<ID3D12PipelineState*>(pso));
}
void D3D12CommandList::SetRenderTargets(uint32_t count, void** renderTargets, void* depthStencil) {
std::vector<ID3D12Resource*> resources(count);
for (uint32_t i = 0; i < count; ++i) {
resources[i] = static_cast<ID3D12Resource*>(renderTargets[i]);
}
SetRenderTargetsInternal(count, resources.data(), static_cast<ID3D12Resource*>(depthStencil));
}
void D3D12CommandList::SetVertexBuffer(uint32_t slot, void* buffer, uint64_t offset, uint32_t stride) {
SetVertexBufferInternal(slot, static_cast<ID3D12Resource*>(buffer), offset, stride);
}
void D3D12CommandList::SetVertexBuffers(uint32_t startSlot, uint32_t count, const uint64_t* buffers, const uint64_t* offsets, const uint32_t* strides) {
std::vector<D3D12_VERTEX_BUFFER_VIEW> views(count);
for (uint32_t i = 0; i < count; ++i) {
views[i].BufferLocation = buffers[i];
views[i].StrideInBytes = strides[i];
views[i].SizeInBytes = 0;
}
SetVertexBuffersInternal(startSlot, count, views.data());
}
void D3D12CommandList::SetIndexBuffer(void* buffer, uint64_t offset, Format format) {
SetIndexBufferInternal(static_cast<ID3D12Resource*>(buffer), offset, format);
}
void D3D12CommandList::Clear(float r, float g, float b, float a, uint32_t buffers) {
float color[4] = { r, g, b, a };
ClearRenderTarget(nullptr, color);
}
void D3D12CommandList::ClearRenderTarget(void* renderTarget, const float color[4]) {
D3D12_CPU_DESCRIPTOR_HANDLE rtvHandle = {};
if (renderTarget) {
}
m_commandList->ClearRenderTargetView(rtvHandle, color, 0, nullptr);
}
void D3D12CommandList::ClearDepthStencil(void* depthStencil, float depth, uint8_t stencil) {
D3D12_CPU_DESCRIPTOR_HANDLE dsvHandle = {};
if (depthStencil) {
}
m_commandList->ClearDepthStencilView(dsvHandle, D3D12_CLEAR_FLAG_DEPTH | D3D12_CLEAR_FLAG_STENCIL, depth, stencil, 0, nullptr);
}
void D3D12CommandList::CopyResource(void* dst, void* src) {
CopyResourceInternal(static_cast<ID3D12Resource*>(dst), static_cast<ID3D12Resource*>(src));
}
void D3D12CommandList::Dispatch(uint32_t x, uint32_t y, uint32_t z) {
m_commandList->Dispatch(x, y, z);
}
void D3D12CommandList::DispatchIndirect(void* argBuffer, uint64_t alignedByteOffset) {
DispatchIndirectInternal(static_cast<ID3D12Resource*>(argBuffer), alignedByteOffset);
}
void D3D12CommandList::DrawInstancedIndirect(void* argBuffer, uint64_t alignedByteOffset) {
DrawInstancedIndirectInternal(static_cast<ID3D12Resource*>(argBuffer), alignedByteOffset);
}
void D3D12CommandList::DrawIndexedInstancedIndirect(void* argBuffer, uint64_t alignedByteOffset) {
DrawIndexedInstancedIndirectInternal(static_cast<ID3D12Resource*>(argBuffer), alignedByteOffset);
}
void D3D12CommandList::TransitionBarrierInternal(ID3D12Resource* resource, ResourceStates stateBefore, ResourceStates stateAfter, uint32_t subresource) {
D3D12_RESOURCE_BARRIER barrier = {};
barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
barrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
barrier.Transition.pResource = resource;
barrier.Transition.StateBefore = ToD3D12(stateBefore);
barrier.Transition.StateAfter = ToD3D12(stateAfter);
barrier.Transition.Subresource = subresource;
m_commandList->ResourceBarrier(1, &barrier);
m_resourceStateMap[resource] = stateAfter;
}
void D3D12CommandList::UAVBarrierInternal(ID3D12Resource* resource) {
D3D12_RESOURCE_BARRIER barrier = {};
barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_UAV;
barrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
barrier.UAV.pResource = resource;
m_commandList->ResourceBarrier(1, &barrier);
}
void D3D12CommandList::AliasBarrierInternal(ID3D12Resource* beforeResource, ID3D12Resource* afterResource) {
D3D12_RESOURCE_BARRIER barrier = {};
barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_ALIASING;
barrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
barrier.Aliasing.pResourceBefore = beforeResource;
barrier.Aliasing.pResourceAfter = afterResource;
m_commandList->ResourceBarrier(1, &barrier);
}
void D3D12CommandList::SetPipelineStateInternal(ID3D12PipelineState* pso) {
m_commandList->SetPipelineState(pso);
m_currentPipelineState = pso;
}
void D3D12CommandList::SetRenderTargetsInternal(uint32_t count, ID3D12Resource** renderTargets, ID3D12Resource* depthStencil) {
std::vector<D3D12_CPU_DESCRIPTOR_HANDLE> rtvHandles(count);
for (uint32_t i = 0; i < count; ++i) {
rtvHandles[i].ptr = 0;
}
D3D12_CPU_DESCRIPTOR_HANDLE dsvHandle = {};
dsvHandle.ptr = 0;
m_commandList->OMSetRenderTargets(count, count > 0 ? rtvHandles.data() : nullptr, FALSE, depthStencil ? &dsvHandle : nullptr);
}
void D3D12CommandList::SetVertexBufferInternal(uint32_t slot, ID3D12Resource* buffer, uint64_t offset, uint32_t stride) {
D3D12_VERTEX_BUFFER_VIEW view = {};
view.BufferLocation = buffer->GetGPUVirtualAddress() + offset;
view.SizeInBytes = static_cast<UINT>(buffer->GetDesc().Width) - static_cast<UINT>(offset);
view.StrideInBytes = stride;
m_commandList->IASetVertexBuffers(slot, 1, &view);
}
void D3D12CommandList::SetVertexBuffersInternal(uint32_t startSlot, uint32_t count, const D3D12_VERTEX_BUFFER_VIEW* views) {
m_commandList->IASetVertexBuffers(startSlot, count, views);
}
void D3D12CommandList::SetIndexBufferInternal(ID3D12Resource* buffer, uint64_t offset, Format indexFormat) {
D3D12_INDEX_BUFFER_VIEW view = {};
view.BufferLocation = buffer->GetGPUVirtualAddress() + offset;
view.SizeInBytes = static_cast<UINT>(buffer->GetDesc().Width) - static_cast<UINT>(offset);
view.Format = ToD3D12(indexFormat);
m_commandList->IASetIndexBuffer(&view);
}
void D3D12CommandList::ClearRenderTargetView(ID3D12Resource* renderTarget, const float color[4], uint32_t rectCount, const D3D12_RECT* rects) {
D3D12_CPU_DESCRIPTOR_HANDLE rtvHandle = {};
m_commandList->ClearRenderTargetView(rtvHandle, color, rectCount, rects);
}
void D3D12CommandList::ClearDepthStencilView(ID3D12Resource* depthStencil, uint32_t clearFlags, float depth, uint8_t stencil, uint32_t rectCount, const D3D12_RECT* rects) {
D3D12_CPU_DESCRIPTOR_HANDLE dsvHandle = {};
m_commandList->ClearDepthStencilView(dsvHandle, static_cast<D3D12_CLEAR_FLAGS>(clearFlags), depth, stencil, rectCount, rects);
}
void D3D12CommandList::CopyResourceInternal(ID3D12Resource* dst, ID3D12Resource* src) {
m_commandList->CopyResource(dst, src);
}
void D3D12CommandList::DispatchIndirectInternal(ID3D12Resource* argBuffer, uint64_t alignedByteOffset) {
m_commandList->ExecuteIndirect(nullptr, 1, argBuffer, alignedByteOffset, nullptr, 0);
}
void D3D12CommandList::DrawInstancedIndirectInternal(ID3D12Resource* argBuffer, uint64_t alignedByteOffset) {
m_commandList->ExecuteIndirect(nullptr, 1, argBuffer, alignedByteOffset, nullptr, 0);
}
void D3D12CommandList::DrawIndexedInstancedIndirectInternal(ID3D12Resource* argBuffer, uint64_t alignedByteOffset) {
m_commandList->ExecuteIndirect(nullptr, 1, argBuffer, alignedByteOffset, nullptr, 0);
}
} // namespace RHI
} // namespace XCEngine

View File

@@ -199,7 +199,15 @@ const RHIDeviceInfo& D3D12Device::GetDeviceInfo() const {
RHIBuffer* D3D12Device::CreateBuffer(const BufferDesc& desc) {
auto* buffer = new D3D12Buffer();
if (buffer->Initialize(m_device.Get(), desc.size, desc.stride, desc.bufferType)) {
D3D12_HEAP_TYPE heapType = D3D12_HEAP_TYPE_DEFAULT;
if (desc.bufferType == static_cast<uint32_t>(BufferType::ReadBack)) {
heapType = D3D12_HEAP_TYPE_READBACK;
} else if (desc.bufferType == static_cast<uint32_t>(BufferType::Constant)) {
heapType = D3D12_HEAP_TYPE_UPLOAD;
}
if (buffer->Initialize(m_device.Get(), desc.size, D3D12_RESOURCE_STATE_COMMON, heapType)) {
buffer->SetStride(desc.stride);
buffer->SetBufferType(static_cast<BufferType>(desc.bufferType));
return buffer;
}
delete buffer;
@@ -208,7 +216,18 @@ RHIBuffer* D3D12Device::CreateBuffer(const BufferDesc& desc) {
RHITexture* D3D12Device::CreateTexture(const TextureDesc& desc) {
auto* texture = new D3D12Texture();
if (texture->Initialize(m_device.Get(), desc)) {
D3D12_RESOURCE_DESC d3d12Desc = {};
d3d12Desc.Dimension = static_cast<D3D12_RESOURCE_DIMENSION>(desc.textureType);
d3d12Desc.Width = desc.width;
d3d12Desc.Height = desc.height;
d3d12Desc.DepthOrArraySize = desc.depth;
d3d12Desc.MipLevels = desc.mipLevels;
d3d12Desc.Format = static_cast<DXGI_FORMAT>(desc.format);
d3d12Desc.SampleDesc.Count = desc.sampleCount;
d3d12Desc.SampleDesc.Quality = desc.sampleQuality;
d3d12Desc.Flags = static_cast<D3D12_RESOURCE_FLAGS>(desc.flags);
d3d12Desc.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN;
if (texture->Initialize(m_device.Get(), d3d12Desc)) {
return texture;
}
delete texture;
@@ -217,7 +236,9 @@ RHITexture* D3D12Device::CreateTexture(const TextureDesc& desc) {
RHIShader* D3D12Device::CompileShader(const ShaderCompileDesc& desc) {
auto* shader = new D3D12Shader();
if (shader->CompileFromFile(desc.fileName.c_str(), desc.entryPoint.c_str(), desc.profile.c_str())) {
if (shader->CompileFromFile(desc.fileName.c_str(),
reinterpret_cast<const char*>(desc.entryPoint.c_str()),
reinterpret_cast<const char*>(desc.profile.c_str()))) {
return shader;
}
delete shader;
@@ -226,7 +247,21 @@ RHIShader* D3D12Device::CompileShader(const ShaderCompileDesc& desc) {
RHISampler* D3D12Device::CreateSampler(const SamplerDesc& desc) {
auto* sampler = new D3D12Sampler();
if (sampler->Initialize(m_device.Get(), desc)) {
D3D12_SAMPLER_DESC d3d12Desc = {};
d3d12Desc.Filter = static_cast<D3D12_FILTER>(desc.filter);
d3d12Desc.AddressU = static_cast<D3D12_TEXTURE_ADDRESS_MODE>(desc.addressU);
d3d12Desc.AddressV = static_cast<D3D12_TEXTURE_ADDRESS_MODE>(desc.addressV);
d3d12Desc.AddressW = static_cast<D3D12_TEXTURE_ADDRESS_MODE>(desc.addressW);
d3d12Desc.MipLODBias = desc.mipLodBias;
d3d12Desc.MaxAnisotropy = desc.maxAnisotropy;
d3d12Desc.ComparisonFunc = static_cast<D3D12_COMPARISON_FUNC>(desc.comparisonFunc);
d3d12Desc.BorderColor[0] = desc.borderColorR;
d3d12Desc.BorderColor[1] = desc.borderColorG;
d3d12Desc.BorderColor[2] = desc.borderColorB;
d3d12Desc.BorderColor[3] = desc.borderColorA;
d3d12Desc.MinLOD = desc.minLod;
d3d12Desc.MaxLOD = desc.maxLod;
if (sampler->Initialize(m_device.Get(), d3d12Desc)) {
return sampler;
}
delete sampler;

View File

@@ -101,7 +101,7 @@ bool D3D12SwapChain::IsFullscreen() const {
return fullscreen != FALSE;
}
void* D3D12SwapChain::GetNativeHandle() const {
void* D3D12SwapChain::GetNativeHandle() {
return reinterpret_cast<void*>(m_swapChain.Get());
}