diff --git a/.gitignore b/.gitignore index 4b8e726a8..729655180 100644 --- a/.gitignore +++ b/.gitignore @@ -228,3 +228,4 @@ ModelManifest.xml /.vs /models/Sample/temp /models/Emitter/temp +*.csv diff --git a/WickedEngine/fontPS.hlsl b/WickedEngine/fontPS.hlsl index 2d06be6b5..b1fc0b667 100644 --- a/WickedEngine/fontPS.hlsl +++ b/WickedEngine/fontPS.hlsl @@ -8,5 +8,5 @@ struct VertextoPixel float4 main(VertextoPixel PSIn) : SV_TARGET { - return texture_0.Sample(sampler_linear_clamp, PSIn.tex) * g_xColor; + return texture_1.Sample(sampler_linear_clamp, PSIn.tex) * g_xColor; } \ No newline at end of file diff --git a/WickedEngine/wiFont.cpp b/WickedEngine/wiFont.cpp index 7bba6cbb8..92192dfc3 100644 --- a/WickedEngine/wiFont.cpp +++ b/WickedEngine/wiFont.cpp @@ -316,7 +316,7 @@ void wiFont::Draw(GRAPHICSTHREAD threadID) assert(text.length() * 4 < 65536 && "The index buffer currently only supports so many characters!"); device->BindIndexBuffer(indexBuffer, INDEXFORMAT_16BIT, 0, threadID); - device->BindResourcePS(fontStyles[style].texture, TEXSLOT_ONDEMAND0, threadID); + device->BindResourcePS(fontStyles[style].texture, TEXSLOT_ONDEMAND1, threadID); wiRenderer::MiscCB cb; diff --git a/WickedEngine/wiGraphicsDevice_DX12.cpp b/WickedEngine/wiGraphicsDevice_DX12.cpp index 5429d92bc..666f9cdd4 100644 --- a/WickedEngine/wiGraphicsDevice_DX12.cpp +++ b/WickedEngine/wiGraphicsDevice_DX12.cpp @@ -1223,14 +1223,19 @@ namespace wiGraphicsTypes descriptorType = type; itemSize = device->GetDescriptorHandleIncrementSize(type); + + boundDescriptors = new D3D12_CPU_DESCRIPTOR_HANDLE*[SHADERSTAGE_COUNT * itemCount]; } GraphicsDevice_DX12::FrameResources::DescriptorTableFrameAllocator::~DescriptorTableFrameAllocator() { SAFE_RELEASE(heap_CPU); SAFE_RELEASE(heap_GPU); + SAFE_DELETE_ARRAY(boundDescriptors); } void GraphicsDevice_DX12::FrameResources::DescriptorTableFrameAllocator::reset(ID3D12Device* device, ID3D12GraphicsCommandList* commandList, D3D12_CPU_DESCRIPTOR_HANDLE* nullDescriptorsSamplerCBVSRVUAV) { + memset(boundDescriptors, 0, sizeof(D3D12_CPU_DESCRIPTOR_HANDLE*)*SHADERSTAGE_COUNT*itemCount); + ringOffset = 0; for (int stage = 0; stage < SHADERSTAGE_COUNT; ++stage) @@ -1281,11 +1286,19 @@ namespace wiGraphicsTypes { return; } + UINT idx = stage * itemCount + offset; + + if (boundDescriptors[idx] == descriptor) + { + return; + } + + boundDescriptors[idx] = descriptor; dirty[stage] = true; D3D12_CPU_DESCRIPTOR_HANDLE dst_staging = heap_CPU->GetCPUDescriptorHandleForHeapStart(); - dst_staging.ptr += (stage * itemCount + offset) * itemSize; + dst_staging.ptr += idx * itemSize; device->CopyDescriptorsSimple(1, dst_staging, *descriptor, (D3D12_DESCRIPTOR_HEAP_TYPE)descriptorType); } @@ -1857,6 +1870,7 @@ namespace wiGraphicsTypes pRects[i].top = INT32_MIN; } static_cast(commandLists[GRAPHICSTHREAD_IMMEDIATE])->RSSetScissorRects(8, pRects); + } GraphicsDevice_DX12::~GraphicsDevice_DX12() { diff --git a/WickedEngine/wiGraphicsDevice_DX12.h b/WickedEngine/wiGraphicsDevice_DX12.h index a4a61c9cd..b38a1de85 100644 --- a/WickedEngine/wiGraphicsDevice_DX12.h +++ b/WickedEngine/wiGraphicsDevice_DX12.h @@ -76,6 +76,7 @@ namespace wiGraphicsTypes UINT itemCount; UINT ringOffset; bool dirty[SHADERSTAGE_COUNT]; + D3D12_CPU_DESCRIPTOR_HANDLE** boundDescriptors; DescriptorTableFrameAllocator(ID3D12Device* device, D3D12_DESCRIPTOR_HEAP_TYPE type, UINT maxRenameCount); ~DescriptorTableFrameAllocator(); @@ -132,6 +133,7 @@ namespace wiGraphicsTypes IDXGISwapChain3* swapChain; ViewPort viewPort; + public: GraphicsDevice_DX12(wiWindowRegistration::window_type window, bool fullscreen = false);