diff --git a/WickedEngine/DeferredRenderableComponent.cpp b/WickedEngine/DeferredRenderableComponent.cpp index 23c17c617..a51e5f650 100644 --- a/WickedEngine/DeferredRenderableComponent.cpp +++ b/WickedEngine/DeferredRenderableComponent.cpp @@ -144,7 +144,7 @@ void DeferredRenderableComponent::RenderScene(GRAPHICSTHREAD threadID) wiRenderer::GetDevice()->TransitionBarrier(dsv, ARRAYSIZE(dsv), RESOURCE_STATE_COPY_SOURCE, RESOURCE_STATE_DEPTH_READ, threadID); - wiRenderer::GetDevice()->UnBindResources(TEXSLOT_ONDEMAND0, TEXSLOT_ONDEMAND_COUNT, threadID); + wiRenderer::GetDevice()->UnbindResources(TEXSLOT_ONDEMAND0, TEXSLOT_ONDEMAND_COUNT, threadID); wiRenderer::UpdateDepthBuffer(dtDepthCopy.GetTexture(), rtLinearDepth.GetTexture(), threadID); @@ -171,7 +171,7 @@ void DeferredRenderableComponent::RenderScene(GRAPHICSTHREAD threadID) if (getSSAOEnabled()) { - wiRenderer::GetDevice()->UnBindResources(TEXSLOT_RENDERABLECOMPONENT_SSAO, 1, threadID); + wiRenderer::GetDevice()->UnbindResources(TEXSLOT_RENDERABLECOMPONENT_SSAO, 1, threadID); wiRenderer::GetDevice()->EventBegin("SSAO", threadID); fx.stencilRef = STENCILREF_DEFAULT; fx.stencilComp = STENCILMODE_LESS; @@ -213,7 +213,7 @@ void DeferredRenderableComponent::RenderScene(GRAPHICSTHREAD threadID) static int sssPassCount = 6; for (int i = 0; i < sssPassCount; ++i) { - wiRenderer::GetDevice()->UnBindResources(TEXSLOT_ONDEMAND0, 1, threadID); + wiRenderer::GetDevice()->UnbindResources(TEXSLOT_ONDEMAND0, 1, threadID); rtSSS[i % 2].Set(threadID, rtGBuffer.depth); XMFLOAT2 dir = XMFLOAT2(0, 0); static float stren = 0.018f; @@ -236,7 +236,7 @@ void DeferredRenderableComponent::RenderScene(GRAPHICSTHREAD threadID) } } fx.process.clear(); - wiRenderer::GetDevice()->UnBindResources(TEXSLOT_ONDEMAND0, 1, threadID); + wiRenderer::GetDevice()->UnbindResources(TEXSLOT_ONDEMAND0, 1, threadID); rtSSS[0].Activate(threadID, rtGBuffer.depth); { fx.setMaskMap(nullptr); fx.quality = QUALITY_NEAREST; @@ -265,7 +265,7 @@ void DeferredRenderableComponent::RenderScene(GRAPHICSTHREAD threadID) } if (getSSREnabled()) { - wiRenderer::GetDevice()->UnBindResources(TEXSLOT_RENDERABLECOMPONENT_SSR, 1, threadID); + wiRenderer::GetDevice()->UnbindResources(TEXSLOT_RENDERABLECOMPONENT_SSR, 1, threadID); wiRenderer::GetDevice()->EventBegin("SSR", threadID); rtSSR.Activate(threadID); { fx.process.clear(); diff --git a/WickedEngine/ForwardRenderableComponent.cpp b/WickedEngine/ForwardRenderableComponent.cpp index dfaa3ec80..00d25ca90 100644 --- a/WickedEngine/ForwardRenderableComponent.cpp +++ b/WickedEngine/ForwardRenderableComponent.cpp @@ -139,7 +139,7 @@ void ForwardRenderableComponent::RenderScene(GRAPHICSTHREAD threadID) if (getSSAOEnabled()) { - wiRenderer::GetDevice()->UnBindResources(TEXSLOT_RENDERABLECOMPONENT_SSAO, 1, threadID); + wiRenderer::GetDevice()->UnbindResources(TEXSLOT_RENDERABLECOMPONENT_SSAO, 1, threadID); wiRenderer::GetDevice()->EventBegin("SSAO", threadID); fx.stencilRef = STENCILREF_DEFAULT; fx.stencilComp = STENCILMODE_LESS; @@ -170,7 +170,7 @@ void ForwardRenderableComponent::RenderScene(GRAPHICSTHREAD threadID) } if (getSSREnabled()) { - wiRenderer::GetDevice()->UnBindResources(TEXSLOT_RENDERABLECOMPONENT_SSR, 1, threadID); + wiRenderer::GetDevice()->UnbindResources(TEXSLOT_RENDERABLECOMPONENT_SSR, 1, threadID); wiRenderer::GetDevice()->EventBegin("SSR", threadID); rtSSR.Activate(threadID); { fx.process.clear(); diff --git a/WickedEngine/Renderable3DComponent.cpp b/WickedEngine/Renderable3DComponent.cpp index 1472899a3..34082a786 100644 --- a/WickedEngine/Renderable3DComponent.cpp +++ b/WickedEngine/Renderable3DComponent.cpp @@ -358,7 +358,7 @@ void Renderable3DComponent::RenderSecondaryScene(wiRenderTarget& mainRT, wiRende if (getLightShaftsEnabled() && XMVectorGetX(XMVector3Dot(wiRenderer::GetSunPosition(), wiRenderer::getCamera()->GetAt())) > 0) { wiRenderer::GetDevice()->EventBegin("Light Shafts", threadID); - wiRenderer::GetDevice()->UnBindResources(TEXSLOT_ONDEMAND0, TEXSLOT_ONDEMAND_COUNT, threadID); + wiRenderer::GetDevice()->UnbindResources(TEXSLOT_ONDEMAND0, TEXSLOT_ONDEMAND_COUNT, threadID); rtSun[0].Activate(threadID, mainRT.depth); { wiRenderer::DrawSun(threadID); } @@ -402,8 +402,8 @@ void Renderable3DComponent::RenderSecondaryScene(wiRenderTarget& mainRT, wiRende wiRenderer::GetDevice()->EventEnd(threadID); } - wiRenderer::GetDevice()->UnBindResources(TEXSLOT_GBUFFER0, 1, threadID); - wiRenderer::GetDevice()->UnBindResources(TEXSLOT_ONDEMAND0, TEXSLOT_ONDEMAND_COUNT, threadID); + wiRenderer::GetDevice()->UnbindResources(TEXSLOT_GBUFFER0, 1, threadID); + wiRenderer::GetDevice()->UnbindResources(TEXSLOT_ONDEMAND0, TEXSLOT_ONDEMAND_COUNT, threadID); if (wiRenderer::GetAdvancedRefractionsEnabled()) { wiRenderer::GenerateMipChain(rtSceneCopy.GetTexture(), wiRenderer::MIPGENFILTER_GAUSSIAN, threadID); @@ -459,7 +459,7 @@ void Renderable3DComponent::RenderSecondaryScene(wiRenderTarget& mainRT, wiRende if (getEmittedParticlesEnabled()) { - wiRenderer::GetDevice()->UnBindResources(TEXSLOT_ONDEMAND0, 1, threadID); + wiRenderer::GetDevice()->UnbindResources(TEXSLOT_ONDEMAND0, 1, threadID); rtParticle.Activate(threadID, 0, 0, 0, 0); wiRenderer::DrawSoftParticles(wiRenderer::getCamera(), true, threadID); } @@ -504,8 +504,8 @@ void Renderable3DComponent::RenderComposition(wiRenderTarget& shadedSceneRT, wiR wiImage::Draw(shadedSceneRT.GetTextureResolvedMSAA(threadID), fx, threadID); fx.process.clear(); } - wiRenderer::GetDevice()->UnBindResources(TEXSLOT_GBUFFER0, 1, threadID); - wiRenderer::GetDevice()->UnBindResources(TEXSLOT_ONDEMAND0, 1, threadID); + wiRenderer::GetDevice()->UnbindResources(TEXSLOT_GBUFFER0, 1, threadID); + wiRenderer::GetDevice()->UnbindResources(TEXSLOT_ONDEMAND0, 1, threadID); shadedSceneRT.Set(threadID, nullptr, false, 0); { fx.presentFullScreen = true; fx.quality = QUALITY_NEAREST; @@ -608,7 +608,7 @@ void Renderable3DComponent::RenderComposition(wiRenderTarget& shadedSceneRT, wiR fx.process.setSharpen(getSharpenFilterAmount()); wiImage::Draw(rt0->GetTexture(), fx, threadID); fx.process.clear(); - wiRenderer::GetDevice()->UnBindResources(TEXSLOT_ONDEMAND0, 1, threadID); + wiRenderer::GetDevice()->UnbindResources(TEXSLOT_ONDEMAND0, 1, threadID); SwapPtr(rt0, rt1); } diff --git a/WickedEngine/TiledDeferredRenderableComponent.cpp b/WickedEngine/TiledDeferredRenderableComponent.cpp index e9fad51ea..ab8902679 100644 --- a/WickedEngine/TiledDeferredRenderableComponent.cpp +++ b/WickedEngine/TiledDeferredRenderableComponent.cpp @@ -57,7 +57,7 @@ void TiledDeferredRenderableComponent::RenderScene(GRAPHICSTHREAD threadID) wiRenderer::GetDevice()->TransitionBarrier(dsv, ARRAYSIZE(dsv), RESOURCE_STATE_COPY_SOURCE, RESOURCE_STATE_DEPTH_READ, threadID); - wiRenderer::GetDevice()->UnBindResources(TEXSLOT_ONDEMAND0, TEXSLOT_ONDEMAND_COUNT, threadID); + wiRenderer::GetDevice()->UnbindResources(TEXSLOT_ONDEMAND0, TEXSLOT_ONDEMAND_COUNT, threadID); wiRenderer::UpdateDepthBuffer(dtDepthCopy.GetTexture(), rtLinearDepth.GetTexture(), threadID); @@ -82,7 +82,7 @@ void TiledDeferredRenderableComponent::RenderScene(GRAPHICSTHREAD threadID) if (getSSAOEnabled()) { - wiRenderer::GetDevice()->UnBindResources(TEXSLOT_RENDERABLECOMPONENT_SSAO, 1, threadID); + wiRenderer::GetDevice()->UnbindResources(TEXSLOT_RENDERABLECOMPONENT_SSAO, 1, threadID); wiRenderer::GetDevice()->EventBegin("SSAO", threadID); fx.stencilRef = STENCILREF_DEFAULT; fx.stencilComp = STENCILMODE_LESS; @@ -124,7 +124,7 @@ void TiledDeferredRenderableComponent::RenderScene(GRAPHICSTHREAD threadID) static int sssPassCount = 6; for (int i = 0; i < sssPassCount; ++i) { - wiRenderer::GetDevice()->UnBindResources(TEXSLOT_ONDEMAND0, 1, threadID); + wiRenderer::GetDevice()->UnbindResources(TEXSLOT_ONDEMAND0, 1, threadID); rtSSS[i % 2].Set(threadID, rtGBuffer.depth); XMFLOAT2 dir = XMFLOAT2(0, 0); static float stren = 0.018f; @@ -147,7 +147,7 @@ void TiledDeferredRenderableComponent::RenderScene(GRAPHICSTHREAD threadID) } } fx.process.clear(); - wiRenderer::GetDevice()->UnBindResources(TEXSLOT_ONDEMAND0, 1, threadID); + wiRenderer::GetDevice()->UnbindResources(TEXSLOT_ONDEMAND0, 1, threadID); rtSSS[0].Activate(threadID, rtGBuffer.depth); { fx.setMaskMap(nullptr); fx.quality = QUALITY_NEAREST; @@ -177,7 +177,7 @@ void TiledDeferredRenderableComponent::RenderScene(GRAPHICSTHREAD threadID) } if (getSSREnabled()) { - wiRenderer::GetDevice()->UnBindResources(TEXSLOT_RENDERABLECOMPONENT_SSR, 1, threadID); + wiRenderer::GetDevice()->UnbindResources(TEXSLOT_RENDERABLECOMPONENT_SSR, 1, threadID); wiRenderer::GetDevice()->EventBegin("SSR", threadID); rtSSR.Activate(threadID); { fx.process.clear(); diff --git a/WickedEngine/TiledForwardRenderableComponent.cpp b/WickedEngine/TiledForwardRenderableComponent.cpp index 15c8f0e52..6d440d6d1 100644 --- a/WickedEngine/TiledForwardRenderableComponent.cpp +++ b/WickedEngine/TiledForwardRenderableComponent.cpp @@ -52,7 +52,7 @@ void TiledForwardRenderableComponent::RenderScene(GRAPHICSTHREAD threadID) wiRenderer::ComputeTiledLightCulling(false, threadID); - wiRenderer::GetDevice()->UnBindResources(TEXSLOT_ONDEMAND0, 1, threadID); + wiRenderer::GetDevice()->UnbindResources(TEXSLOT_ONDEMAND0, 1, threadID); wiProfiler::GetInstance().BeginRange("Opaque Scene", wiProfiler::DOMAIN_GPU, threadID); rtMain.Set(threadID); @@ -69,7 +69,7 @@ void TiledForwardRenderableComponent::RenderScene(GRAPHICSTHREAD threadID) if (getSSAOEnabled()) { - wiRenderer::GetDevice()->UnBindResources(TEXSLOT_RENDERABLECOMPONENT_SSAO, 1, threadID); + wiRenderer::GetDevice()->UnbindResources(TEXSLOT_RENDERABLECOMPONENT_SSAO, 1, threadID); wiRenderer::GetDevice()->EventBegin("SSAO", threadID); fx.stencilRef = STENCILREF_DEFAULT; fx.stencilComp = STENCILMODE_LESS; @@ -100,7 +100,7 @@ void TiledForwardRenderableComponent::RenderScene(GRAPHICSTHREAD threadID) } if (getSSREnabled()) { - wiRenderer::GetDevice()->UnBindResources(TEXSLOT_RENDERABLECOMPONENT_SSR, 1, threadID); + wiRenderer::GetDevice()->UnbindResources(TEXSLOT_RENDERABLECOMPONENT_SSR, 1, threadID); wiRenderer::GetDevice()->EventBegin("SSR", threadID); rtSSR.Activate(threadID); { fx.process.clear(); diff --git a/WickedEngine/wiEmittedParticle.cpp b/WickedEngine/wiEmittedParticle.cpp index 62052ab7a..1436adef1 100644 --- a/WickedEngine/wiEmittedParticle.cpp +++ b/WickedEngine/wiEmittedParticle.cpp @@ -374,7 +374,7 @@ void wiEmittedParticle::UpdateRenderData(GRAPHICSTHREAD threadID) indirectBuffers, distanceBuffer, }; - device->BindUnorderedAccessResourcesCS(uavs, 0, ARRAYSIZE(uavs), threadID); + device->BindUAVs(CS, uavs, 0, ARRAYSIZE(uavs), threadID); GPUResource* resources[] = { wiTextureHelper::getInstance()->getRandom64x64(), @@ -415,7 +415,7 @@ void wiEmittedParticle::UpdateRenderData(GRAPHICSTHREAD threadID) // 1.) Assign particles into partitioning grid: device->EventBegin("Partitioning", threadID); device->BindComputePSO(&CPSO_sphpartition, threadID); - device->UnBindUnorderedAccessResources(0, 8, threadID); + device->UnbindUAVs(0, 8, threadID); GPUResource* res_partition[] = { aliveList[0], // CURRENT alivelist counterBuffer, @@ -425,7 +425,7 @@ void wiEmittedParticle::UpdateRenderData(GRAPHICSTHREAD threadID) GPUResource* uav_partition[] = { sphPartitionCellIndices, }; - device->BindUnorderedAccessResourcesCS(uav_partition, 0, ARRAYSIZE(uav_partition), threadID); + device->BindUAVs(CS, uav_partition, 0, ARRAYSIZE(uav_partition), threadID); device->DispatchIndirect(indirectBuffers, ARGUMENTBUFFER_OFFSET_DISPATCHSIMULATION, threadID); device->UAVBarrier(uav_partition, ARRAYSIZE(uav_partition), threadID); device->EventEnd(threadID); @@ -436,11 +436,11 @@ void wiEmittedParticle::UpdateRenderData(GRAPHICSTHREAD threadID) // 3.) Reset grid cell offset buffer with invalid offsets (max uint): device->EventBegin("PartitionOffsetsReset", threadID); device->BindComputePSO(&CPSO_sphpartitionoffsetsreset, threadID); - device->UnBindUnorderedAccessResources(0, 8, threadID); + device->UnbindUAVs(0, 8, threadID); GPUResource* uav_partitionoffsets[] = { sphPartitionCellOffsets, }; - device->BindUnorderedAccessResourcesCS(uav_partitionoffsets, 0, ARRAYSIZE(uav_partitionoffsets), threadID); + device->BindUAVs(CS, uav_partitionoffsets, 0, ARRAYSIZE(uav_partitionoffsets), threadID); device->Dispatch((UINT)ceilf((float)SPH_PARTITION_BUCKET_COUNT / (float)THREADCOUNT_SIMULATION), 1, 1, threadID); device->UAVBarrier(uav_partitionoffsets, ARRAYSIZE(uav_partitionoffsets), threadID); device->EventEnd(threadID); @@ -463,7 +463,7 @@ void wiEmittedParticle::UpdateRenderData(GRAPHICSTHREAD threadID) // 5.) Compute particle density field: device->EventBegin("Density Evaluation", threadID); device->BindComputePSO(&CPSO_sphdensity, threadID); - device->UnBindUnorderedAccessResources(0, 8, threadID); + device->UnbindUAVs(0, 8, threadID); GPUResource* res_density[] = { aliveList[0], // CURRENT alivelist counterBuffer, @@ -475,7 +475,7 @@ void wiEmittedParticle::UpdateRenderData(GRAPHICSTHREAD threadID) GPUResource* uav_density[] = { densityBuffer }; - device->BindUnorderedAccessResourcesCS(uav_density, 0, ARRAYSIZE(uav_density), threadID); + device->BindUAVs(CS, uav_density, 0, ARRAYSIZE(uav_density), threadID); device->DispatchIndirect(indirectBuffers, ARGUMENTBUFFER_OFFSET_DISPATCHSIMULATION, threadID); device->UAVBarrier(uav_density, ARRAYSIZE(uav_density), threadID); device->EventEnd(threadID); @@ -483,7 +483,7 @@ void wiEmittedParticle::UpdateRenderData(GRAPHICSTHREAD threadID) // 6.) Compute particle pressure forces: device->EventBegin("Force Evaluation", threadID); device->BindComputePSO(&CPSO_sphforce, threadID); - device->UnBindUnorderedAccessResources(0, 8, threadID); + device->UnbindUAVs(0, 8, threadID); GPUResource* res_force[] = { aliveList[0], // CURRENT alivelist counterBuffer, @@ -495,13 +495,13 @@ void wiEmittedParticle::UpdateRenderData(GRAPHICSTHREAD threadID) GPUResource* uav_force[] = { particleBuffer, }; - device->BindUnorderedAccessResourcesCS(uav_force, 0, ARRAYSIZE(uav_force), threadID); + device->BindUAVs(CS, uav_force, 0, ARRAYSIZE(uav_force), threadID); device->DispatchIndirect(indirectBuffers, ARGUMENTBUFFER_OFFSET_DISPATCHSIMULATION, threadID); device->UAVBarrier(uav_force, ARRAYSIZE(uav_force), threadID); device->EventEnd(threadID); - device->UnBindResources(0, 3, threadID); - device->UnBindUnorderedAccessResources(0, 8, threadID); + device->UnbindResources(0, 3, threadID); + device->UnbindUAVs(0, 8, threadID); device->EventEnd(threadID); @@ -509,7 +509,7 @@ void wiEmittedParticle::UpdateRenderData(GRAPHICSTHREAD threadID) } device->EventBegin("Simulate", threadID); - device->BindUnorderedAccessResourcesCS(uavs, 0, ARRAYSIZE(uavs), threadID); + device->BindUAVs(CS, uavs, 0, ARRAYSIZE(uavs), threadID); device->BindResources(CS, resources, TEXSLOT_ONDEMAND0, ARRAYSIZE(resources), threadID); // update CURRENT alive list, write NEW alive list @@ -540,8 +540,8 @@ void wiEmittedParticle::UpdateRenderData(GRAPHICSTHREAD threadID) device->EventEnd(threadID); - device->UnBindUnorderedAccessResources(0, ARRAYSIZE(uavs), threadID); - device->UnBindResources(TEXSLOT_ONDEMAND0, ARRAYSIZE(resources), threadID); + device->UnbindUAVs(0, ARRAYSIZE(uavs), threadID); + device->UnbindResources(TEXSLOT_ONDEMAND0, ARRAYSIZE(resources), threadID); device->EventEnd(threadID); @@ -629,13 +629,13 @@ void wiEmittedParticle::UpdateRenderData(GRAPHICSTHREAD threadID) GPUResource* uavs[] = { indirectBuffers, }; - device->BindUnorderedAccessResourcesCS(uavs, 0, ARRAYSIZE(uavs), threadID); + device->BindUAVs(CS, uavs, 0, ARRAYSIZE(uavs), threadID); device->Dispatch(1, 1, 1, threadID); device->UAVBarrier(uavs, ARRAYSIZE(uavs), threadID); - device->UnBindUnorderedAccessResources(0, ARRAYSIZE(uavs), threadID); - device->UnBindResources(0, ARRAYSIZE(res), threadID); + device->UnbindUAVs(0, ARRAYSIZE(uavs), threadID); + device->UnbindResources(0, ARRAYSIZE(res), threadID); device->EventEnd(threadID); diff --git a/WickedEngine/wiFFTGenerator.cpp b/WickedEngine/wiFFTGenerator.cpp index 640edd40f..4bbabb5f7 100644 --- a/WickedEngine/wiFFTGenerator.cpp +++ b/WickedEngine/wiFFTGenerator.cpp @@ -30,7 +30,7 @@ void radix008A(CSFFT512x512_Plan* fft_plan, device->BindResources(CS, cs_srvs, TEXSLOT_ONDEMAND0, 1, threadID); GPUResource* cs_uavs[1] = { pUAV_Dst }; - device->BindUnorderedAccessResourcesCS(cs_uavs, 0, ARRAYSIZE(cs_uavs), threadID); + device->BindUAVs(CS, cs_uavs, 0, ARRAYSIZE(cs_uavs), threadID); // Shader if (istride > 1) @@ -50,8 +50,8 @@ void radix008A(CSFFT512x512_Plan* fft_plan, device->UAVBarrier(cs_uavs, ARRAYSIZE(cs_uavs), threadID); // Unbind resource - device->UnBindResources(TEXSLOT_ONDEMAND0, 1, threadID); - device->UnBindUnorderedAccessResources(0, 1, threadID); + device->UnbindResources(TEXSLOT_ONDEMAND0, 1, threadID); + device->UnbindUAVs(0, 1, threadID); } void fft_512x512_c2c(CSFFT512x512_Plan* fft_plan, diff --git a/WickedEngine/wiGPUSortLib.cpp b/WickedEngine/wiGPUSortLib.cpp index 721daa35d..fe4d65111 100644 --- a/WickedEngine/wiGPUSortLib.cpp +++ b/WickedEngine/wiGPUSortLib.cpp @@ -90,7 +90,7 @@ void wiGPUSortLib::Sort(UINT maxCount, GPUBuffer* comparisonBuffer_read, GPUBuff device->UpdateBuffer(sortCB, &sc, threadID); device->BindConstantBuffer(CS, sortCB, CB_GETBINDSLOT(SortConstants), threadID); - device->UnBindUnorderedAccessResources(0, 8, threadID); + device->UnbindUAVs(0, 8, threadID); // initialize sorting arguments: { @@ -104,19 +104,19 @@ void wiGPUSortLib::Sort(UINT maxCount, GPUBuffer* comparisonBuffer_read, GPUBuff GPUResource* uavs[] = { indirectBuffer, }; - device->BindUnorderedAccessResourcesCS(uavs, 0, ARRAYSIZE(uavs), threadID); + device->BindUAVs(CS, uavs, 0, ARRAYSIZE(uavs), threadID); device->Dispatch(1, 1, 1, threadID); device->UAVBarrier(uavs, ARRAYSIZE(uavs), threadID); - device->UnBindUnorderedAccessResources(0, ARRAYSIZE(uavs), threadID); + device->UnbindUAVs(0, ARRAYSIZE(uavs), threadID); } GPUResource* uavs[] = { indexBuffer_write, }; - device->BindUnorderedAccessResourcesCS(uavs, 0, ARRAYSIZE(uavs), threadID); + device->BindUAVs(CS, uavs, 0, ARRAYSIZE(uavs), threadID); GPUResource* resources[] = { counterBuffer_read, @@ -200,8 +200,8 @@ void wiGPUSortLib::Sort(UINT maxCount, GPUBuffer* comparisonBuffer_read, GPUBuff presorted *= 2; } - device->UnBindUnorderedAccessResources(0, ARRAYSIZE(uavs), threadID); - device->UnBindResources(0, ARRAYSIZE(resources), threadID); + device->UnbindUAVs(0, ARRAYSIZE(uavs), threadID); + device->UnbindResources(0, ARRAYSIZE(resources), threadID); device->EventEnd(threadID); diff --git a/WickedEngine/wiGUI.cpp b/WickedEngine/wiGUI.cpp index e014dff23..3a0196485 100644 --- a/WickedEngine/wiGUI.cpp +++ b/WickedEngine/wiGUI.cpp @@ -90,7 +90,7 @@ void wiGUI::ResetScissor() scissor[0].left = (LONG)(0); scissor[0].right = (LONG)(wiRenderer::GetDevice()->GetScreenWidth()); scissor[0].top = (LONG)(0); - wiRenderer::GetDevice()->SetScissorRects(1, scissor, GetGraphicsThread()); + wiRenderer::GetDevice()->BindScissorRects(1, scissor, GetGraphicsThread()); } void wiGUI::AddWidget(wiWidget* widget) diff --git a/WickedEngine/wiGraphicsDevice.h b/WickedEngine/wiGraphicsDevice.h index 090362eda..5a06906b1 100644 --- a/WickedEngine/wiGraphicsDevice.h +++ b/WickedEngine/wiGraphicsDevice.h @@ -89,18 +89,17 @@ namespace wiGraphicsTypes ///////////////Thread-sensitive//////////////////////// + virtual void BindScissorRects(UINT numRects, const Rect* rects, GRAPHICSTHREAD threadID) = 0; virtual void BindViewports(UINT NumViewports, const ViewPort *pViewports, GRAPHICSTHREAD threadID) = 0; - virtual void BindRenderTargetsUAVs(UINT NumViews, Texture2D* const *ppRenderTargets, Texture2D* depthStencilTexture, GPUResource* const *ppUAVs, int slotUAV, int countUAV, - GRAPHICSTHREAD threadID, int arrayIndex = -1) = 0; virtual void BindRenderTargets(UINT NumViews, Texture2D* const *ppRenderTargets, Texture2D* depthStencilTexture, GRAPHICSTHREAD threadID, int arrayIndex = -1) = 0; virtual void ClearRenderTarget(Texture* pTexture, const FLOAT ColorRGBA[4], GRAPHICSTHREAD threadID, int arrayIndex = -1) = 0; virtual void ClearDepthStencil(Texture2D* pTexture, UINT ClearFlags, FLOAT Depth, UINT8 Stencil, GRAPHICSTHREAD threadID, int arrayIndex = -1) = 0; virtual void BindResource(SHADERSTAGE stage, GPUResource* resource, int slot, GRAPHICSTHREAD threadID, int arrayIndex = -1) = 0; virtual void BindResources(SHADERSTAGE stage, GPUResource *const* resources, int slot, int count, GRAPHICSTHREAD threadID) = 0; - virtual void BindUnorderedAccessResourceCS(GPUResource* resource, int slot, GRAPHICSTHREAD threadID, int arrayIndex = -1) = 0; - virtual void BindUnorderedAccessResourcesCS(GPUResource *const* resources, int slot, int count, GRAPHICSTHREAD threadID) = 0; - virtual void UnBindResources(int slot, int num, GRAPHICSTHREAD threadID) = 0; - virtual void UnBindUnorderedAccessResources(int slot, int num, GRAPHICSTHREAD threadID) = 0; + virtual void BindUAV(SHADERSTAGE stage, GPUResource* resource, int slot, GRAPHICSTHREAD threadID, int arrayIndex = -1) = 0; + virtual void BindUAVs(SHADERSTAGE stage, GPUResource *const* resources, int slot, int count, GRAPHICSTHREAD threadID) = 0; + virtual void UnbindResources(int slot, int num, GRAPHICSTHREAD threadID) = 0; + virtual void UnbindUAVs(int slot, int num, GRAPHICSTHREAD threadID) = 0; virtual void BindSampler(SHADERSTAGE stage, Sampler* sampler, int slot, GRAPHICSTHREAD threadID) = 0; virtual void BindConstantBuffer(SHADERSTAGE stage, GPUBuffer* buffer, int slot, GRAPHICSTHREAD threadID) = 0; virtual void BindVertexBuffers(GPUBuffer *const* vertexBuffers, int slot, int count, const UINT* strides, const UINT* offsets, GRAPHICSTHREAD threadID) = 0; @@ -125,7 +124,6 @@ namespace wiGraphicsTypes virtual void* AllocateFromRingBuffer(GPURingBuffer* buffer, size_t dataSize, UINT& offsetIntoBuffer, GRAPHICSTHREAD threadID) = 0; virtual void InvalidateBufferAccess(GPUBuffer* buffer, GRAPHICSTHREAD threadID) = 0; virtual bool DownloadBuffer(GPUBuffer* bufferToDownload, GPUBuffer* bufferDest, void* dataDest, GRAPHICSTHREAD threadID) = 0; - virtual void SetScissorRects(UINT numRects, const Rect* rects, GRAPHICSTHREAD threadID) = 0; virtual void QueryBegin(GPUQuery *query, GRAPHICSTHREAD threadID) = 0; virtual void QueryEnd(GPUQuery *query, GRAPHICSTHREAD threadID) = 0; virtual bool QueryRead(GPUQuery *query, GRAPHICSTHREAD threadID) = 0; diff --git a/WickedEngine/wiGraphicsDevice_DX11.cpp b/WickedEngine/wiGraphicsDevice_DX11.cpp index 049c1ed59..069371b70 100644 --- a/WickedEngine/wiGraphicsDevice_DX11.cpp +++ b/WickedEngine/wiGraphicsDevice_DX11.cpp @@ -2779,6 +2779,10 @@ void GraphicsDevice_DX11::PresentEnd() memset(prev_il, 0, sizeof(prev_il)); memset(prev_pt, 0, sizeof(prev_pt)); + memset(raster_uavs, 0, sizeof(raster_uavs)); + memset(raster_uavs_slot, 8, sizeof(raster_uavs_slot)); + memset(raster_uavs_count, 0, sizeof(raster_uavs_count)); + FRAMECOUNT++; RESOLUTIONCHANGED = false; @@ -2807,6 +2811,37 @@ void GraphicsDevice_DX11::FinishCommandList(GRAPHICSTHREAD thread) deviceContexts[thread]->FinishCommandList(true, &commandLists[thread]); } + +void GraphicsDevice_DX11::validate_raster_uavs(GRAPHICSTHREAD threadID) +{ + // This is a helper function to defer the graphics stage UAV bindings to OMSetRenderTargetsAndUnorderedAccessViews (if there was an update) + // It is intended to be called before graphics stage executions (eg. Draw) + // It is also explicitly maintained in BindRenderTargets function, because in that case, we will also bind some render targets in the same call + + if(raster_uavs_count[threadID] > 0) + { + const UINT count = raster_uavs_count[threadID]; + const UINT slot = raster_uavs_slot[threadID]; + + deviceContexts[threadID]->OMSetRenderTargetsAndUnorderedAccessViews(0, nullptr, nullptr, slot, count, &raster_uavs[threadID][slot], nullptr); + + raster_uavs_count[threadID] = 0; + raster_uavs_slot[threadID] = 8; + } +} + +void GraphicsDevice_DX11::BindScissorRects(UINT numRects, const Rect* rects, GRAPHICSTHREAD threadID) { + assert(rects != nullptr); + assert(numRects <= 8); + D3D11_RECT pRects[8]; + for(UINT i = 0; i < numRects; ++i) { + pRects[i].bottom = rects[i].bottom; + pRects[i].left = rects[i].left; + pRects[i].right = rects[i].right; + pRects[i].top = rects[i].top; + } + deviceContexts[threadID]->RSSetScissorRects(numRects, pRects); +} void GraphicsDevice_DX11::BindViewports(UINT NumViewports, const ViewPort *pViewports, GRAPHICSTHREAD threadID) { assert(NumViewports <= 6); @@ -2822,51 +2857,6 @@ void GraphicsDevice_DX11::BindViewports(UINT NumViewports, const ViewPort *pView } deviceContexts[threadID]->RSSetViewports(NumViewports, d3dViewPorts); } -void GraphicsDevice_DX11::BindRenderTargetsUAVs(UINT NumViews, Texture2D* const *ppRenderTargets, Texture2D* depthStencilTexture, GPUResource* const *ppUAVs, int slotUAV, int countUAV, - GRAPHICSTHREAD threadID, int arrayIndex) -{ - // RTVs: - ID3D11RenderTargetView* renderTargetViews[8]; - ZeroMemory(renderTargetViews, sizeof(renderTargetViews)); - for (UINT i = 0; i < min(NumViews, 8); ++i) - { - if (arrayIndex < 0 || ppRenderTargets[i]->additionalRTVs_DX11.empty()) - { - renderTargetViews[i] = ppRenderTargets[i]->RTV_DX11; - } - else - { - assert(ppRenderTargets[i]->additionalRTVs_DX11.size() > static_cast(arrayIndex) && "Invalid rendertarget arrayIndex!"); - renderTargetViews[i] = ppRenderTargets[i]->additionalRTVs_DX11[arrayIndex]; - } - } - - // DSVs: - ID3D11DepthStencilView* depthStencilView = nullptr; - if (depthStencilTexture != nullptr) - { - if (arrayIndex < 0 || depthStencilTexture->additionalDSVs_DX11.empty()) - { - depthStencilView = depthStencilTexture->DSV_DX11; - } - else - { - assert(depthStencilTexture->additionalDSVs_DX11.size() > static_cast(arrayIndex) && "Invalid depthstencil arrayIndex!"); - depthStencilView = depthStencilTexture->additionalDSVs_DX11[arrayIndex]; - } - } - - // UAVs: - ID3D11UnorderedAccessView* UAVs[8]; - ZeroMemory(UAVs, sizeof(UAVs)); - for (int i = 0; i < min(countUAV, 8); ++i) - { - UAVs[i] = ppUAVs[i]->UAV_DX11; - } - - - deviceContexts[threadID]->OMSetRenderTargetsAndUnorderedAccessViews(NumViews, renderTargetViews, depthStencilView, slotUAV, countUAV, UAVs, nullptr); -} void GraphicsDevice_DX11::BindRenderTargets(UINT NumViews, Texture2D* const *ppRenderTargets, Texture2D* depthStencilTexture, GRAPHICSTHREAD threadID, int arrayIndex) { // RTVs: @@ -2900,7 +2890,21 @@ void GraphicsDevice_DX11::BindRenderTargets(UINT NumViews, Texture2D* const *ppR } } - deviceContexts[threadID]->OMSetRenderTargets(NumViews, renderTargetViews, depthStencilView); + if(raster_uavs_count[threadID] > 0) + { + // UAVs: + const UINT count = raster_uavs_count[threadID]; + const UINT slot = raster_uavs_slot[threadID]; + + deviceContexts[threadID]->OMSetRenderTargetsAndUnorderedAccessViews(NumViews, renderTargetViews, depthStencilView, slot, count, &raster_uavs[threadID][slot], nullptr); + + raster_uavs_count[threadID] = 0; + raster_uavs_slot[threadID] = 8; + } + else + { + deviceContexts[threadID]->OMSetRenderTargets(NumViews, renderTargetViews, depthStencilView); + } } void GraphicsDevice_DX11::ClearRenderTarget(Texture* pTexture, const FLOAT ColorRGBA[4], GRAPHICSTHREAD threadID, int arrayIndex) { @@ -3028,32 +3032,65 @@ void GraphicsDevice_DX11::BindResources(SHADERSTAGE stage, GPUResource *const* r break; } } -void GraphicsDevice_DX11::BindUnorderedAccessResourceCS(GPUResource* resource, int slot, GRAPHICSTHREAD threadID, int arrayIndex) +void GraphicsDevice_DX11::BindUAV(SHADERSTAGE stage, GPUResource* resource, int slot, GRAPHICSTHREAD threadID, int arrayIndex) { if (resource != nullptr) { if (arrayIndex < 0) { - deviceContexts[threadID]->CSSetUnorderedAccessViews(slot, 1, &resource->UAV_DX11, nullptr); + if(stage == CS) + { + deviceContexts[threadID]->CSSetUnorderedAccessViews(slot, 1, &resource->UAV_DX11, nullptr); + } + else + { + raster_uavs[threadID][slot] = resource->UAV_DX11; + raster_uavs_slot[threadID] = min(raster_uavs_slot[threadID], slot); + raster_uavs_count[threadID] = max(raster_uavs_count[threadID], 1); + } } else { assert(resource->additionalUAVs_DX11.size() > static_cast(arrayIndex) && "Invalid arrayIndex!"); - deviceContexts[threadID]->CSSetUnorderedAccessViews(slot, 1, &resource->additionalUAVs_DX11[arrayIndex], nullptr); + + if(stage == CS) + { + deviceContexts[threadID]->CSSetUnorderedAccessViews(slot, 1, &resource->additionalUAVs_DX11[arrayIndex], nullptr); + } + else + { + raster_uavs[threadID][slot] = resource->additionalUAVs_DX11[arrayIndex]; + raster_uavs_slot[threadID] = min(raster_uavs_slot[threadID], slot); + raster_uavs_count[threadID] = max(raster_uavs_count[threadID], 1); + } } } } -void GraphicsDevice_DX11::BindUnorderedAccessResourcesCS(GPUResource *const* resources, int slot, int count, GRAPHICSTHREAD threadID) +void GraphicsDevice_DX11::BindUAVs(SHADERSTAGE stage, GPUResource *const* resources, int slot, int count, GRAPHICSTHREAD threadID) { - assert(count <= 8); + assert(slot + count <= 8); ID3D11UnorderedAccessView* uavs[8]; for (int i = 0; i < count; ++i) { uavs[i] = resources[i] != nullptr ? resources[i]->UAV_DX11 : nullptr; + + if(stage != CS) + { + raster_uavs[threadID][slot + i] = uavs[i]; + } + } + + if(stage == CS) + { + deviceContexts[threadID]->CSSetUnorderedAccessViews(static_cast(slot), static_cast(count), uavs, nullptr); + } + else + { + raster_uavs_slot[threadID] = min(raster_uavs_slot[threadID], slot); + raster_uavs_count[threadID] = max(raster_uavs_count[threadID], count); } - deviceContexts[threadID]->CSSetUnorderedAccessViews(static_cast(slot), static_cast(count), uavs, nullptr); } -void GraphicsDevice_DX11::UnBindResources(int slot, int num, GRAPHICSTHREAD threadID) +void GraphicsDevice_DX11::UnbindResources(int slot, int num, GRAPHICSTHREAD threadID) { assert(num <= ARRAYSIZE(__nullBlob) && "Extend nullBlob to support more resource unbinding!"); deviceContexts[threadID]->PSSetShaderResources(slot, num, (ID3D11ShaderResourceView**)__nullBlob); @@ -3063,10 +3100,13 @@ void GraphicsDevice_DX11::UnBindResources(int slot, int num, GRAPHICSTHREAD thre deviceContexts[threadID]->DSSetShaderResources(slot, num, (ID3D11ShaderResourceView**)__nullBlob); deviceContexts[threadID]->CSSetShaderResources(slot, num, (ID3D11ShaderResourceView**)__nullBlob); } -void GraphicsDevice_DX11::UnBindUnorderedAccessResources(int slot, int num, GRAPHICSTHREAD threadID) +void GraphicsDevice_DX11::UnbindUAVs(int slot, int num, GRAPHICSTHREAD threadID) { assert(num <= ARRAYSIZE(__nullBlob) && "Extend nullBlob to support more resource unbinding!"); deviceContexts[threadID]->CSSetUnorderedAccessViews(slot, num, (ID3D11UnorderedAccessView**)__nullBlob, 0); + + raster_uavs_count[threadID] = 0; + raster_uavs_slot[threadID] = 8; } void GraphicsDevice_DX11::BindSampler(SHADERSTAGE stage, Sampler* sampler, int slot, GRAPHICSTHREAD threadID) { @@ -3138,7 +3178,6 @@ void GraphicsDevice_DX11::BindIndexBuffer(GPUBuffer* indexBuffer, const INDEXBUF ID3D11Buffer* res = indexBuffer != nullptr ? indexBuffer->resource_DX11 : nullptr; deviceContexts[threadID]->IASetIndexBuffer(res, (format == INDEXBUFFER_FORMAT::INDEXFORMAT_16BIT ? DXGI_FORMAT_R16_UINT : DXGI_FORMAT_R32_UINT), offset); } - void GraphicsDevice_DX11::BindStencilRef(UINT value, GRAPHICSTHREAD threadID) { stencilRef[threadID] = value; @@ -3262,26 +3301,38 @@ void GraphicsDevice_DX11::BindComputePSO(ComputePSO* pso, GRAPHICSTHREAD threadI } void GraphicsDevice_DX11::Draw(int vertexCount, UINT startVertexLocation, GRAPHICSTHREAD threadID) { + validate_raster_uavs(threadID); + deviceContexts[threadID]->Draw(vertexCount, startVertexLocation); } void GraphicsDevice_DX11::DrawIndexed(int indexCount, UINT startIndexLocation, UINT baseVertexLocation, GRAPHICSTHREAD threadID) { + validate_raster_uavs(threadID); + deviceContexts[threadID]->DrawIndexed(indexCount, startIndexLocation, baseVertexLocation); } void GraphicsDevice_DX11::DrawInstanced(int vertexCount, int instanceCount, UINT startVertexLocation, UINT startInstanceLocation, GRAPHICSTHREAD threadID) { + validate_raster_uavs(threadID); + deviceContexts[threadID]->DrawInstanced(vertexCount, instanceCount, startVertexLocation, startInstanceLocation); } void GraphicsDevice_DX11::DrawIndexedInstanced(int indexCount, int instanceCount, UINT startIndexLocation, UINT baseVertexLocation, UINT startInstanceLocation, GRAPHICSTHREAD threadID) { + validate_raster_uavs(threadID); + deviceContexts[threadID]->DrawIndexedInstanced(indexCount, instanceCount, startIndexLocation, baseVertexLocation, startInstanceLocation); } void GraphicsDevice_DX11::DrawInstancedIndirect(GPUBuffer* args, UINT args_offset, GRAPHICSTHREAD threadID) { + validate_raster_uavs(threadID); + deviceContexts[threadID]->DrawInstancedIndirect(args->resource_DX11, args_offset); } void GraphicsDevice_DX11::DrawIndexedInstancedIndirect(GPUBuffer* args, UINT args_offset, GRAPHICSTHREAD threadID) { + validate_raster_uavs(threadID); + deviceContexts[threadID]->DrawIndexedInstancedIndirect(args->resource_DX11, args_offset); } void GraphicsDevice_DX11::Dispatch(UINT threadGroupCountX, UINT threadGroupCountY, UINT threadGroupCountZ, GRAPHICSTHREAD threadID) @@ -3405,20 +3456,6 @@ bool GraphicsDevice_DX11::DownloadBuffer(GPUBuffer* bufferToDownload, GPUBuffer* return result; } -void GraphicsDevice_DX11::SetScissorRects(UINT numRects, const Rect* rects, GRAPHICSTHREAD threadID) -{ - assert(rects != nullptr); - assert(numRects <= 8); - D3D11_RECT pRects[8]; - for (UINT i = 0; i < numRects; ++i) - { - pRects[i].bottom = rects[i].bottom; - pRects[i].left = rects[i].left; - pRects[i].right = rects[i].right; - pRects[i].top = rects[i].top; - } - deviceContexts[threadID]->RSSetScissorRects(numRects, pRects); -} void GraphicsDevice_DX11::WaitForGPU() { diff --git a/WickedEngine/wiGraphicsDevice_DX11.h b/WickedEngine/wiGraphicsDevice_DX11.h index bb0b82c6b..eb1b68cea 100644 --- a/WickedEngine/wiGraphicsDevice_DX11.h +++ b/WickedEngine/wiGraphicsDevice_DX11.h @@ -47,6 +47,11 @@ namespace wiGraphicsTypes ID3D11InputLayout* prev_il[GRAPHICSTHREAD_COUNT] = {}; PRIMITIVETOPOLOGY prev_pt[GRAPHICSTHREAD_COUNT] = {}; + ID3D11UnorderedAccessView* raster_uavs[GRAPHICSTHREAD_COUNT][8] = {}; + uint8_t raster_uavs_slot[GRAPHICSTHREAD_COUNT] = {}; + uint8_t raster_uavs_count[GRAPHICSTHREAD_COUNT] = {}; + void validate_raster_uavs(GRAPHICSTHREAD threadID); + public: GraphicsDevice_DX11(wiWindowRegistration::window_type window, bool fullscreen = false, bool debuglayer = false); @@ -84,18 +89,17 @@ namespace wiGraphicsTypes ///////////////Thread-sensitive//////////////////////// + virtual void BindScissorRects(UINT numRects, const Rect* rects, GRAPHICSTHREAD threadID) override; virtual void BindViewports(UINT NumViewports, const ViewPort *pViewports, GRAPHICSTHREAD threadID) override; - virtual void BindRenderTargetsUAVs(UINT NumViews, Texture2D* const *ppRenderTargets, Texture2D* depthStencilTexture, GPUResource* const *ppUAVs, int slotUAV, int countUAV, - GRAPHICSTHREAD threadID, int arrayIndex = -1) override; virtual void BindRenderTargets(UINT NumViews, Texture2D* const *ppRenderTargets, Texture2D* depthStencilTexture, GRAPHICSTHREAD threadID, int arrayIndex = -1) override; virtual void ClearRenderTarget(Texture* pTexture, const FLOAT ColorRGBA[4], GRAPHICSTHREAD threadID, int arrayIndex = -1) override; virtual void ClearDepthStencil(Texture2D* pTexture, UINT ClearFlags, FLOAT Depth, UINT8 Stencil, GRAPHICSTHREAD threadID, int arrayIndex = -1) override; virtual void BindResource(SHADERSTAGE stage, GPUResource* resource, int slot, GRAPHICSTHREAD threadID, int arrayIndex = -1) override; virtual void BindResources(SHADERSTAGE stage, GPUResource *const* resources, int slot, int count, GRAPHICSTHREAD threadID) override; - virtual void BindUnorderedAccessResourceCS(GPUResource* resource, int slot, GRAPHICSTHREAD threadID, int arrayIndex = -1) override; - virtual void BindUnorderedAccessResourcesCS(GPUResource *const* resources, int slot, int count, GRAPHICSTHREAD threadID) override; - virtual void UnBindResources(int slot, int num, GRAPHICSTHREAD threadID) override; - virtual void UnBindUnorderedAccessResources(int slot, int num, GRAPHICSTHREAD threadID) override; + virtual void BindUAV(SHADERSTAGE stage, GPUResource* resource, int slot, GRAPHICSTHREAD threadID, int arrayIndex = -1) override; + virtual void BindUAVs(SHADERSTAGE stage, GPUResource *const* resources, int slot, int count, GRAPHICSTHREAD threadID) override; + virtual void UnbindResources(int slot, int num, GRAPHICSTHREAD threadID) override; + virtual void UnbindUAVs(int slot, int num, GRAPHICSTHREAD threadID) override; virtual void BindSampler(SHADERSTAGE stage, Sampler* sampler, int slot, GRAPHICSTHREAD threadID) override; virtual void BindConstantBuffer(SHADERSTAGE stage, GPUBuffer* buffer, int slot, GRAPHICSTHREAD threadID) override; virtual void BindVertexBuffers(GPUBuffer* const *vertexBuffers, int slot, int count, const UINT* strides, const UINT* offsets, GRAPHICSTHREAD threadID) override; @@ -120,7 +124,6 @@ namespace wiGraphicsTypes virtual void* AllocateFromRingBuffer(GPURingBuffer* buffer, size_t dataSize, UINT& offsetIntoBuffer, GRAPHICSTHREAD threadID) override; virtual void InvalidateBufferAccess(GPUBuffer* buffer, GRAPHICSTHREAD threadID) override; virtual bool DownloadBuffer(GPUBuffer* bufferToDownload, GPUBuffer* bufferDest, void* dataDest, GRAPHICSTHREAD threadID) override; - virtual void SetScissorRects(UINT numRects, const Rect* rects, GRAPHICSTHREAD threadID) override; virtual void QueryBegin(GPUQuery *query, GRAPHICSTHREAD threadID) override; virtual void QueryEnd(GPUQuery *query, GRAPHICSTHREAD threadID) override; virtual bool QueryRead(GPUQuery *query, GRAPHICSTHREAD threadID) override; diff --git a/WickedEngine/wiGraphicsDevice_DX12.cpp b/WickedEngine/wiGraphicsDevice_DX12.cpp index 51cafeb42..761703798 100644 --- a/WickedEngine/wiGraphicsDevice_DX12.cpp +++ b/WickedEngine/wiGraphicsDevice_DX12.cpp @@ -3154,6 +3154,18 @@ namespace wiGraphicsTypes } + void GraphicsDevice_DX12::BindScissorRects(UINT numRects, const Rect* rects, GRAPHICSTHREAD threadID) { + assert(rects != nullptr); + assert(numRects <= 8); + D3D12_RECT pRects[8]; + for(UINT i = 0; i < numRects; ++i) { + pRects[i].bottom = rects[i].bottom; + pRects[i].left = rects[i].left; + pRects[i].right = rects[i].right; + pRects[i].top = rects[i].top; + } + GetDirectCommandList(threadID)->RSSetScissorRects(numRects, pRects); + } void GraphicsDevice_DX12::BindViewports(UINT NumViewports, const ViewPort *pViewports, GRAPHICSTHREAD threadID) { assert(NumViewports <= 6); @@ -3169,19 +3181,6 @@ namespace wiGraphicsTypes } GetDirectCommandList(threadID)->RSSetViewports(NumViewports, d3dViewPorts); } - void GraphicsDevice_DX12::BindRenderTargetsUAVs(UINT NumViews, Texture2D* const *ppRenderTargets, Texture2D* depthStencilTexture, GPUResource* const *ppUAVs, int slotUAV, int countUAV, - GRAPHICSTHREAD threadID, int arrayIndex) - { - BindRenderTargets(NumViews, ppRenderTargets, depthStencilTexture, threadID, arrayIndex); - - if (ppUAVs != nullptr) - { - for (int i = 0; i < countUAV; ++i) - { - BindUnorderedAccessResource(PS, ppUAVs[i], slotUAV + i, threadID, -1); - } - } - } void GraphicsDevice_DX12::BindRenderTargets(UINT NumViews, Texture2D* const *ppRenderTargets, Texture2D* depthStencilTexture, GRAPHICSTHREAD threadID, int arrayIndex) { D3D12_CPU_DESCRIPTOR_HANDLE descriptors[8] = {}; @@ -3283,7 +3282,7 @@ namespace wiGraphicsTypes } } } - void GraphicsDevice_DX12::BindUnorderedAccessResource(SHADERSTAGE stage, GPUResource* resource, int slot, GRAPHICSTHREAD threadID, int arrayIndex) + void GraphicsDevice_DX12::BindUAV(SHADERSTAGE stage, GPUResource* resource, int slot, GRAPHICSTHREAD threadID, int arrayIndex) { assert(slot < GPU_RESOURCE_HEAP_UAV_COUNT); @@ -3305,25 +3304,17 @@ namespace wiGraphicsTypes } } } - void GraphicsDevice_DX12::BindUnorderedAccessResources(SHADERSTAGE stage, GPUResource *const* resources, int slot, int count, GRAPHICSTHREAD threadID) + void GraphicsDevice_DX12::BindUAVs(SHADERSTAGE stage, GPUResource *const* resources, int slot, int count, GRAPHICSTHREAD threadID) { if (resources != nullptr) { for (int i = 0; i < count; ++i) { - BindUnorderedAccessResource(stage, resources[i], slot + i, threadID, -1); + BindUAV(stage, resources[i], slot + i, threadID, -1); } } } - void GraphicsDevice_DX12::BindUnorderedAccessResourceCS(GPUResource* resource, int slot, GRAPHICSTHREAD threadID, int arrayIndex) - { - BindUnorderedAccessResource(CS, resource, slot, threadID, arrayIndex); - } - void GraphicsDevice_DX12::BindUnorderedAccessResourcesCS(GPUResource *const* resources, int slot, int count, GRAPHICSTHREAD threadID) - { - BindUnorderedAccessResources(CS, resources, slot, count, threadID); - } - void GraphicsDevice_DX12::UnBindResources(int slot, int num, GRAPHICSTHREAD threadID) + void GraphicsDevice_DX12::UnbindResources(int slot, int num, GRAPHICSTHREAD threadID) { for (int stage = 0; stage < SHADERSTAGE_COUNT; ++stage) { @@ -3334,7 +3325,7 @@ namespace wiGraphicsTypes } } } - void GraphicsDevice_DX12::UnBindUnorderedAccessResources(int slot, int num, GRAPHICSTHREAD threadID) + void GraphicsDevice_DX12::UnbindUAVs(int slot, int num, GRAPHICSTHREAD threadID) { for (int stage = 0; stage < SHADERSTAGE_COUNT; ++stage) { @@ -3638,20 +3629,6 @@ namespace wiGraphicsTypes { return false; } - void GraphicsDevice_DX12::SetScissorRects(UINT numRects, const Rect* rects, GRAPHICSTHREAD threadID) - { - assert(rects != nullptr); - assert(numRects <= 8); - D3D12_RECT pRects[8]; - for (UINT i = 0; i < numRects; ++i) - { - pRects[i].bottom = rects[i].bottom; - pRects[i].left = rects[i].left; - pRects[i].right = rects[i].right; - pRects[i].top = rects[i].top; - } - GetDirectCommandList(threadID)->RSSetScissorRects(numRects, pRects); - } void GraphicsDevice_DX12::WaitForGPU() { diff --git a/WickedEngine/wiGraphicsDevice_DX12.h b/WickedEngine/wiGraphicsDevice_DX12.h index 3c6faa17d..67429b865 100644 --- a/WickedEngine/wiGraphicsDevice_DX12.h +++ b/WickedEngine/wiGraphicsDevice_DX12.h @@ -176,20 +176,17 @@ namespace wiGraphicsTypes ///////////////Thread-sensitive//////////////////////// + virtual void BindScissorRects(UINT numRects, const Rect* rects, GRAPHICSTHREAD threadID) override; virtual void BindViewports(UINT NumViewports, const ViewPort *pViewports, GRAPHICSTHREAD threadID) override; - virtual void BindRenderTargetsUAVs(UINT NumViews, Texture2D* const *ppRenderTargets, Texture2D* depthStencilTexture, GPUResource* const *ppUAVs, int slotUAV, int countUAV, - GRAPHICSTHREAD threadID, int arrayIndex = -1) override; virtual void BindRenderTargets(UINT NumViews, Texture2D* const *ppRenderTargets, Texture2D* depthStencilTexture, GRAPHICSTHREAD threadID, int arrayIndex = -1) override; virtual void ClearRenderTarget(Texture* pTexture, const FLOAT ColorRGBA[4], GRAPHICSTHREAD threadID, int arrayIndex = -1) override; virtual void ClearDepthStencil(Texture2D* pTexture, UINT ClearFlags, FLOAT Depth, UINT8 Stencil, GRAPHICSTHREAD threadID, int arrayIndex = -1) override; virtual void BindResource(SHADERSTAGE stage, GPUResource* resource, int slot, GRAPHICSTHREAD threadID, int arrayIndex = -1) override; virtual void BindResources(SHADERSTAGE stage, GPUResource *const* resources, int slot, int count, GRAPHICSTHREAD threadID) override; - void BindUnorderedAccessResource(SHADERSTAGE stage, GPUResource* resource, int slot, GRAPHICSTHREAD threadID, int arrayIndex = -1); - void BindUnorderedAccessResources(SHADERSTAGE stage, GPUResource *const* resources, int slot, int count, GRAPHICSTHREAD threadID); - virtual void BindUnorderedAccessResourceCS(GPUResource* resource, int slot, GRAPHICSTHREAD threadID, int arrayIndex = -1) override; - virtual void BindUnorderedAccessResourcesCS(GPUResource *const* resources, int slot, int count, GRAPHICSTHREAD threadID) override; - virtual void UnBindResources(int slot, int num, GRAPHICSTHREAD threadID) override; - virtual void UnBindUnorderedAccessResources(int slot, int num, GRAPHICSTHREAD threadID) override; + virtual void BindUAV(SHADERSTAGE stage, GPUResource* resource, int slot, GRAPHICSTHREAD threadID, int arrayIndex = -1) override; + virtual void BindUAVs(SHADERSTAGE stage, GPUResource *const* resources, int slot, int count, GRAPHICSTHREAD threadID) override; + virtual void UnbindResources(int slot, int num, GRAPHICSTHREAD threadID) override; + virtual void UnbindUAVs(int slot, int num, GRAPHICSTHREAD threadID) override; virtual void BindSampler(SHADERSTAGE stage, Sampler* sampler, int slot, GRAPHICSTHREAD threadID) override; virtual void BindConstantBuffer(SHADERSTAGE stage, GPUBuffer* buffer, int slot, GRAPHICSTHREAD threadID) override; virtual void BindVertexBuffers(GPUBuffer* const *vertexBuffers, int slot, int count, const UINT* strides, const UINT* offsets, GRAPHICSTHREAD threadID) override; @@ -214,7 +211,6 @@ namespace wiGraphicsTypes virtual void* AllocateFromRingBuffer(GPURingBuffer* buffer, size_t dataSize, UINT& offsetIntoBuffer, GRAPHICSTHREAD threadID) override; virtual void InvalidateBufferAccess(GPUBuffer* buffer, GRAPHICSTHREAD threadID) override; virtual bool DownloadBuffer(GPUBuffer* bufferToDownload, GPUBuffer* bufferDest, void* dataDest, GRAPHICSTHREAD threadID) override; - virtual void SetScissorRects(UINT numRects, const Rect* rects, GRAPHICSTHREAD threadID) override; virtual void QueryBegin(GPUQuery *query, GRAPHICSTHREAD threadID) override; virtual void QueryEnd(GPUQuery *query, GRAPHICSTHREAD threadID) override; virtual bool QueryRead(GPUQuery *query, GRAPHICSTHREAD threadID) override; diff --git a/WickedEngine/wiGraphicsDevice_Vulkan.cpp b/WickedEngine/wiGraphicsDevice_Vulkan.cpp index 986500349..011bb022f 100644 --- a/WickedEngine/wiGraphicsDevice_Vulkan.cpp +++ b/WickedEngine/wiGraphicsDevice_Vulkan.cpp @@ -4201,6 +4201,18 @@ namespace wiGraphicsTypes } + void GraphicsDevice_Vulkan::BindScissorRects(UINT numRects, const Rect* rects, GRAPHICSTHREAD threadID) { + assert(rects != nullptr); + assert(numRects <= 8); + VkRect2D scissors[8]; + for(UINT i = 0; i < numRects; ++i) { + scissors[i].extent.width = abs(rects[i].right - rects[i].left); + scissors[i].extent.height = abs(rects[i].top - rects[i].bottom); + scissors[i].offset.x = max(0, rects[i].left); + scissors[i].offset.y = max(0, rects[i].top); + } + vkCmdSetScissor(GetDirectCommandList(threadID), 0, numRects, scissors); + } void GraphicsDevice_Vulkan::BindViewports(UINT NumViewports, const ViewPort *pViewports, GRAPHICSTHREAD threadID) { assert(NumViewports <= 6); @@ -4216,19 +4228,6 @@ namespace wiGraphicsTypes } vkCmdSetViewport(GetDirectCommandList(threadID), 0, NumViewports, viewports); } - void GraphicsDevice_Vulkan::BindRenderTargetsUAVs(UINT NumViews, Texture2D* const *ppRenderTargets, Texture2D* depthStencilTexture, GPUResource* const *ppUAVs, int slotUAV, int countUAV, - GRAPHICSTHREAD threadID, int arrayIndex) - { - BindRenderTargets(NumViews, ppRenderTargets, depthStencilTexture, threadID, arrayIndex); - - if (ppUAVs != nullptr) - { - for (int i = 0; i < countUAV; ++i) - { - BindUnorderedAccessResource(PS, ppUAVs[i], slotUAV + i, threadID, -1); - } - } - } void GraphicsDevice_Vulkan::BindRenderTargets(UINT NumViews, Texture2D* const *ppRenderTargets, Texture2D* depthStencilTexture, GRAPHICSTHREAD threadID, int arrayIndex) { assert(NumViews <= 8); @@ -4401,7 +4400,7 @@ namespace wiGraphicsTypes } } } - void GraphicsDevice_Vulkan::BindUnorderedAccessResource(SHADERSTAGE stage, GPUResource* resource, int slot, GRAPHICSTHREAD threadID, int arrayIndex) + void GraphicsDevice_Vulkan::BindUAV(SHADERSTAGE stage, GPUResource* resource, int slot, GRAPHICSTHREAD threadID, int arrayIndex) { assert(slot < GPU_RESOURCE_HEAP_UAV_COUNT); @@ -4517,28 +4516,20 @@ namespace wiGraphicsTypes } } } - void GraphicsDevice_Vulkan::BindUnorderedAccessResources(SHADERSTAGE stage, GPUResource *const* resources, int slot, int count, GRAPHICSTHREAD threadID) + void GraphicsDevice_Vulkan::BindUAVs(SHADERSTAGE stage, GPUResource *const* resources, int slot, int count, GRAPHICSTHREAD threadID) { if (resources != nullptr) { for (int i = 0; i < count; ++i) { - BindUnorderedAccessResource(stage, resources[i], slot + i, threadID, -1); + BindUAV(stage, resources[i], slot + i, threadID, -1); } } } - void GraphicsDevice_Vulkan::BindUnorderedAccessResourceCS(GPUResource* resource, int slot, GRAPHICSTHREAD threadID, int arrayIndex) - { - BindUnorderedAccessResource(CS, resource, slot, threadID, arrayIndex); - } - void GraphicsDevice_Vulkan::BindUnorderedAccessResourcesCS(GPUResource *const* resources, int slot, int count, GRAPHICSTHREAD threadID) - { - BindUnorderedAccessResources(CS, resources, slot, count, threadID); - } - void GraphicsDevice_Vulkan::UnBindResources(int slot, int num, GRAPHICSTHREAD threadID) + void GraphicsDevice_Vulkan::UnbindResources(int slot, int num, GRAPHICSTHREAD threadID) { } - void GraphicsDevice_Vulkan::UnBindUnorderedAccessResources(int slot, int num, GRAPHICSTHREAD threadID) + void GraphicsDevice_Vulkan::UnbindUAVs(int slot, int num, GRAPHICSTHREAD threadID) { } void GraphicsDevice_Vulkan::BindSampler(SHADERSTAGE stage, Sampler* sampler, int slot, GRAPHICSTHREAD threadID) @@ -4963,20 +4954,6 @@ namespace wiGraphicsTypes { return false; } - void GraphicsDevice_Vulkan::SetScissorRects(UINT numRects, const Rect* rects, GRAPHICSTHREAD threadID) - { - assert(rects != nullptr); - assert(numRects <= 8); - VkRect2D scissors[8]; - for (UINT i = 0; i < numRects; ++i) - { - scissors[i].extent.width = abs(rects[i].right - rects[i].left); - scissors[i].extent.height = abs(rects[i].top - rects[i].bottom); - scissors[i].offset.x = max(0, rects[i].left); - scissors[i].offset.y = max(0, rects[i].top); - } - vkCmdSetScissor(GetDirectCommandList(threadID), 0, numRects, scissors); - } void GraphicsDevice_Vulkan::WaitForGPU() { diff --git a/WickedEngine/wiGraphicsDevice_Vulkan.h b/WickedEngine/wiGraphicsDevice_Vulkan.h index ced9ce37d..01843b9e5 100644 --- a/WickedEngine/wiGraphicsDevice_Vulkan.h +++ b/WickedEngine/wiGraphicsDevice_Vulkan.h @@ -225,20 +225,17 @@ namespace wiGraphicsTypes ///////////////Thread-sensitive//////////////////////// + virtual void BindScissorRects(UINT numRects, const Rect* rects, GRAPHICSTHREAD threadID) override; virtual void BindViewports(UINT NumViewports, const ViewPort *pViewports, GRAPHICSTHREAD threadID) override; - virtual void BindRenderTargetsUAVs(UINT NumViews, Texture2D* const *ppRenderTargets, Texture2D* depthStencilTexture, GPUResource* const *ppUAVs, int slotUAV, int countUAV, - GRAPHICSTHREAD threadID, int arrayIndex = -1) override; virtual void BindRenderTargets(UINT NumViews, Texture2D* const *ppRenderTargets, Texture2D* depthStencilTexture, GRAPHICSTHREAD threadID, int arrayIndex = -1) override; virtual void ClearRenderTarget(Texture* pTexture, const FLOAT ColorRGBA[4], GRAPHICSTHREAD threadID, int arrayIndex = -1) override; virtual void ClearDepthStencil(Texture2D* pTexture, UINT ClearFlags, FLOAT Depth, UINT8 Stencil, GRAPHICSTHREAD threadID, int arrayIndex = -1) override; virtual void BindResource(SHADERSTAGE stage, GPUResource* resource, int slot, GRAPHICSTHREAD threadID, int arrayIndex = -1) override; virtual void BindResources(SHADERSTAGE stage, GPUResource *const* resources, int slot, int count, GRAPHICSTHREAD threadID) override; - void BindUnorderedAccessResource(SHADERSTAGE stage, GPUResource* resource, int slot, GRAPHICSTHREAD threadID, int arrayIndex = -1); - void BindUnorderedAccessResources(SHADERSTAGE stage, GPUResource *const* resources, int slot, int count, GRAPHICSTHREAD threadID); - virtual void BindUnorderedAccessResourceCS(GPUResource* resource, int slot, GRAPHICSTHREAD threadID, int arrayIndex = -1) override; - virtual void BindUnorderedAccessResourcesCS(GPUResource *const* resources, int slot, int count, GRAPHICSTHREAD threadID) override; - virtual void UnBindResources(int slot, int num, GRAPHICSTHREAD threadID) override; - virtual void UnBindUnorderedAccessResources(int slot, int num, GRAPHICSTHREAD threadID) override; + virtual void BindUAV(SHADERSTAGE stage, GPUResource* resource, int slot, GRAPHICSTHREAD threadID, int arrayIndex = -1) override; + virtual void BindUAVs(SHADERSTAGE stage, GPUResource *const* resources, int slot, int count, GRAPHICSTHREAD threadID) override; + virtual void UnbindResources(int slot, int num, GRAPHICSTHREAD threadID) override; + virtual void UnbindUAVs(int slot, int num, GRAPHICSTHREAD threadID) override; virtual void BindSampler(SHADERSTAGE stage, Sampler* sampler, int slot, GRAPHICSTHREAD threadID) override; virtual void BindConstantBuffer(SHADERSTAGE stage, GPUBuffer* buffer, int slot, GRAPHICSTHREAD threadID) override; virtual void BindVertexBuffers(GPUBuffer* const *vertexBuffers, int slot, int count, const UINT* strides, const UINT* offsets, GRAPHICSTHREAD threadID) override; @@ -263,7 +260,6 @@ namespace wiGraphicsTypes virtual void* AllocateFromRingBuffer(GPURingBuffer* buffer, size_t dataSize, UINT& offsetIntoBuffer, GRAPHICSTHREAD threadID) override; virtual void InvalidateBufferAccess(GPUBuffer* buffer, GRAPHICSTHREAD threadID) override; virtual bool DownloadBuffer(GPUBuffer* bufferToDownload, GPUBuffer* bufferDest, void* dataDest, GRAPHICSTHREAD threadID) override; - virtual void SetScissorRects(UINT numRects, const Rect* rects, GRAPHICSTHREAD threadID) override; virtual void QueryBegin(GPUQuery *query, GRAPHICSTHREAD threadID) override; virtual void QueryEnd(GPUQuery *query, GRAPHICSTHREAD threadID) override; virtual bool QueryRead(GPUQuery *query, GRAPHICSTHREAD threadID) override; diff --git a/WickedEngine/wiOcean.cpp b/WickedEngine/wiOcean.cpp index 7a51aed97..1d95f1860 100644 --- a/WickedEngine/wiOcean.cpp +++ b/WickedEngine/wiOcean.cpp @@ -261,7 +261,7 @@ void wiOcean::UpdateDisplacementMap(float time, GRAPHICSTHREAD threadID) device->BindResources(CS, cs0_srvs, TEXSLOT_ONDEMAND0, ARRAYSIZE(cs0_srvs), threadID); GPUResource* cs0_uavs[1] = { m_pBuffer_Float2_Ht }; - device->BindUnorderedAccessResourcesCS(cs0_uavs, 0, ARRAYSIZE(cs0_uavs), threadID); + device->BindUAVs(CS, cs0_uavs, 0, ARRAYSIZE(cs0_uavs), threadID); Ocean_Simulation_PerFrameCB perFrameData; perFrameData.g_Time = time * m_param.time_scale; @@ -278,8 +278,8 @@ void wiOcean::UpdateDisplacementMap(float time, GRAPHICSTHREAD threadID) device->Dispatch(group_count_x, group_count_y, 1, threadID); device->UAVBarrier(cs0_uavs, ARRAYSIZE(cs0_uavs), threadID); - device->UnBindUnorderedAccessResources(0, 1, threadID); - device->UnBindResources(TEXSLOT_ONDEMAND0, 2, threadID); + device->UnbindUAVs(0, 1, threadID); + device->UnbindResources(TEXSLOT_ONDEMAND0, 2, threadID); // ------------------------------------ Perform FFT ------------------------------------------- @@ -294,7 +294,7 @@ void wiOcean::UpdateDisplacementMap(float time, GRAPHICSTHREAD threadID) // Update displacement map: device->BindComputePSO(&CPSO_updateDisplacementMap, threadID); GPUResource* cs_uavs[] = { m_pDisplacementMap }; - device->BindUnorderedAccessResourcesCS(cs_uavs, 0, 1, threadID); + device->BindUAVs(CS, cs_uavs, 0, 1, threadID); GPUResource* cs_srvs[1] = { m_pBuffer_Float_Dxyz }; device->BindResources(CS, cs_srvs, TEXSLOT_ONDEMAND0, 1, threadID); device->Dispatch(m_param.dmap_dim / OCEAN_COMPUTE_TILESIZE, m_param.dmap_dim / OCEAN_COMPUTE_TILESIZE, 1, threadID); @@ -303,15 +303,15 @@ void wiOcean::UpdateDisplacementMap(float time, GRAPHICSTHREAD threadID) // Update gradient map: device->BindComputePSO(&CPSO_updateGradientFolding, threadID); cs_uavs[0] = { m_pGradientMap }; - device->BindUnorderedAccessResourcesCS(cs_uavs, 0, 1, threadID); + device->BindUAVs(CS, cs_uavs, 0, 1, threadID); cs_srvs[0] = m_pDisplacementMap; device->BindResources(CS, cs_srvs, TEXSLOT_ONDEMAND0, 1, threadID); device->Dispatch(m_param.dmap_dim / OCEAN_COMPUTE_TILESIZE, m_param.dmap_dim / OCEAN_COMPUTE_TILESIZE, 1, threadID); device->UAVBarrier(cs_uavs, ARRAYSIZE(cs_uavs), threadID); // Unbind - device->UnBindUnorderedAccessResources(0, 1, threadID); - device->UnBindResources(TEXSLOT_ONDEMAND0, 1, threadID); + device->UnbindUAVs(0, 1, threadID); + device->UnbindResources(TEXSLOT_ONDEMAND0, 1, threadID); device->GenerateMips(m_pGradientMap, threadID); diff --git a/WickedEngine/wiRenderer.cpp b/WickedEngine/wiRenderer.cpp index a645d3174..f4a588f69 100644 --- a/WickedEngine/wiRenderer.cpp +++ b/WickedEngine/wiRenderer.cpp @@ -3504,7 +3504,7 @@ void wiRenderer::UpdateRenderData(GRAPHICSTHREAD threadID) }; GetDevice()->BindResources(CS, vbs, SKINNINGSLOT_IN_VERTEX_POS, ARRAYSIZE(vbs), threadID); - GetDevice()->BindUnorderedAccessResourcesCS(sos, 0, ARRAYSIZE(sos), threadID); + GetDevice()->BindUAVs(CS, sos, 0, ARRAYSIZE(sos), threadID); GetDevice()->Dispatch((UINT)ceilf((float)mesh->vertices_POS.size() / SKINNING_COMPUTE_THREADCOUNT), 1, 1, threadID); GetDevice()->UAVBarrier(sos, ARRAYSIZE(sos), threadID); // todo: defer @@ -3528,8 +3528,8 @@ void wiRenderer::UpdateRenderData(GRAPHICSTHREAD threadID) if (streamOutSetUp) { - GetDevice()->UnBindUnorderedAccessResources(0, 2, threadID); - GetDevice()->UnBindResources(SKINNINGSLOT_IN_VERTEX_POS, 2, threadID); + GetDevice()->UnbindUAVs(0, 2, threadID); + GetDevice()->UnbindResources(SKINNINGSLOT_IN_VERTEX_POS, 2, threadID); } } @@ -4820,7 +4820,7 @@ void wiRenderer::DrawForShadowMap(GRAPHICSTHREAD threadID, uint32_t layerMask) if (!culledLights.empty()) { - GetDevice()->UnBindResources(TEXSLOT_SHADOWARRAY_2D, 2, threadID); + GetDevice()->UnbindResources(TEXSLOT_SHADOWARRAY_2D, 2, threadID); int shadowCounter_2D = 0; int shadowCounter_Cube = 0; @@ -5867,7 +5867,9 @@ void wiRenderer::VoxelRadiance(GRAPHICSTHREAD threadID) return; } - GetDevice()->EventBegin("Voxel Radiance", threadID); + GraphicsDevice* device = GetDevice(); + + device->EventBegin("Voxel Radiance", threadID); wiProfiler::GetInstance().BeginRange("Voxel Radiance", wiProfiler::DOMAIN_GPU, threadID); @@ -5888,7 +5890,7 @@ void wiRenderer::VoxelRadiance(GRAPHICSTHREAD threadID) textures[TEXTYPE_3D_VOXELRADIANCE] = new Texture3D; textures[TEXTYPE_3D_VOXELRADIANCE]->RequestIndependentShaderResourcesForMIPs(true); textures[TEXTYPE_3D_VOXELRADIANCE]->RequestIndependentUnorderedAccessResourcesForMIPs(true); - HRESULT hr = GetDevice()->CreateTexture3D(&desc, nullptr, (Texture3D**)&textures[TEXTYPE_3D_VOXELRADIANCE]); + HRESULT hr = device->CreateTexture3D(&desc, nullptr, (Texture3D**)&textures[TEXTYPE_3D_VOXELRADIANCE]); assert(SUCCEEDED(hr)); } if (voxelSceneData.secondaryBounceEnabled && textures[TEXTYPE_3D_VOXELRADIANCE_HELPER] == nullptr) @@ -5897,7 +5899,7 @@ void wiRenderer::VoxelRadiance(GRAPHICSTHREAD threadID) textures[TEXTYPE_3D_VOXELRADIANCE_HELPER] = new Texture3D; textures[TEXTYPE_3D_VOXELRADIANCE_HELPER]->RequestIndependentShaderResourcesForMIPs(true); textures[TEXTYPE_3D_VOXELRADIANCE_HELPER]->RequestIndependentUnorderedAccessResourcesForMIPs(true); - HRESULT hr = GetDevice()->CreateTexture3D(&desc, nullptr, (Texture3D**)&textures[TEXTYPE_3D_VOXELRADIANCE_HELPER]); + HRESULT hr = device->CreateTexture3D(&desc, nullptr, (Texture3D**)&textures[TEXTYPE_3D_VOXELRADIANCE_HELPER]); assert(SUCCEEDED(hr)); } if (resourceBuffers[RBTYPE_VOXELSCENE] == nullptr) @@ -5911,7 +5913,7 @@ void wiRenderer::VoxelRadiance(GRAPHICSTHREAD threadID) desc.Usage = USAGE_DEFAULT; resourceBuffers[RBTYPE_VOXELSCENE] = new GPUBuffer; - HRESULT hr = GetDevice()->CreateBuffer(&desc, nullptr, resourceBuffers[RBTYPE_VOXELSCENE]); + HRESULT hr = device->CreateBuffer(&desc, nullptr, resourceBuffers[RBTYPE_VOXELSCENE]); assert(SUCCEEDED(hr)); } @@ -5940,58 +5942,59 @@ void wiRenderer::VoxelRadiance(GRAPHICSTHREAD threadID) VP.Height = (float)voxelSceneData.res; VP.MinDepth = 0.0f; VP.MaxDepth = 1.0f; - GetDevice()->BindViewports(1, &VP, threadID); + device->BindViewports(1, &VP, threadID); GPUResource* UAVs[] = { resourceBuffers[RBTYPE_VOXELSCENE] }; - GetDevice()->BindRenderTargetsUAVs(0, nullptr, nullptr, UAVs, 0, 1, threadID); + //device->BindRenderTargetsUAVs(0, nullptr, nullptr, UAVs, 0, 1, threadID); + device->BindUAVs(PS, UAVs, 0, 1, threadID); RenderMeshes(center, culledRenderer, SHADERTYPE_VOXELIZE, RENDERTYPE_OPAQUE, threadID); // Copy the packed voxel scene data to a 3D texture, then delete the voxel scene emission data. The cone tracing will operate on the 3D texture - GetDevice()->EventBegin("Voxel Scene Copy - Clear", threadID); - GetDevice()->BindRenderTargets(0, nullptr, nullptr, threadID); - GetDevice()->BindUnorderedAccessResourceCS(resourceBuffers[RBTYPE_VOXELSCENE], 0, threadID); - GetDevice()->BindUnorderedAccessResourceCS(textures[TEXTYPE_3D_VOXELRADIANCE], 1, threadID); + device->EventBegin("Voxel Scene Copy - Clear", threadID); + device->BindRenderTargets(0, nullptr, nullptr, threadID); + device->BindUAV(CS, resourceBuffers[RBTYPE_VOXELSCENE], 0, threadID); + device->BindUAV(CS, textures[TEXTYPE_3D_VOXELRADIANCE], 1, threadID); - if (GetDevice()->CheckCapability(GraphicsDevice::GRAPHICSDEVICE_CAPABILITY_UNORDEREDACCESSTEXTURE_LOAD_FORMAT_EXT)) + if (device->CheckCapability(GraphicsDevice::GRAPHICSDEVICE_CAPABILITY_UNORDEREDACCESSTEXTURE_LOAD_FORMAT_EXT)) { - GetDevice()->BindComputePSO(CPSO[CSTYPE_VOXELSCENECOPYCLEAR_TEMPORALSMOOTHING], threadID); + device->BindComputePSO(CPSO[CSTYPE_VOXELSCENECOPYCLEAR_TEMPORALSMOOTHING], threadID); } else { - GetDevice()->BindComputePSO(CPSO[CSTYPE_VOXELSCENECOPYCLEAR], threadID); + device->BindComputePSO(CPSO[CSTYPE_VOXELSCENECOPYCLEAR], threadID); } - GetDevice()->Dispatch((UINT)(voxelSceneData.res * voxelSceneData.res * voxelSceneData.res / 256), 1, 1, threadID); - GetDevice()->EventEnd(threadID); + device->Dispatch((UINT)(voxelSceneData.res * voxelSceneData.res * voxelSceneData.res / 256), 1, 1, threadID); + device->EventEnd(threadID); if (voxelSceneData.secondaryBounceEnabled) { - GetDevice()->EventBegin("Voxel Radiance Secondary Bounce", threadID); - GetDevice()->UnBindUnorderedAccessResources(1, 1, threadID); + device->EventBegin("Voxel Radiance Secondary Bounce", threadID); + device->UnbindUAVs(1, 1, threadID); // Pre-integrate the voxel texture by creating blurred mip levels: GenerateMipChain((Texture3D*)textures[TEXTYPE_3D_VOXELRADIANCE], MIPGENFILTER_LINEAR, threadID); - GetDevice()->BindUnorderedAccessResourceCS(textures[TEXTYPE_3D_VOXELRADIANCE_HELPER], 0, threadID); - GetDevice()->BindResource(CS, textures[TEXTYPE_3D_VOXELRADIANCE], 0, threadID); - GetDevice()->BindResource(CS, resourceBuffers[RBTYPE_VOXELSCENE], 1, threadID); - GetDevice()->BindComputePSO(CPSO[CSTYPE_VOXELRADIANCESECONDARYBOUNCE], threadID); - GetDevice()->Dispatch((UINT)(voxelSceneData.res * voxelSceneData.res * voxelSceneData.res / 64), 1, 1, threadID); - GetDevice()->EventEnd(threadID); + device->BindUAV(CS, textures[TEXTYPE_3D_VOXELRADIANCE_HELPER], 0, threadID); + device->BindResource(CS, textures[TEXTYPE_3D_VOXELRADIANCE], 0, threadID); + device->BindResource(CS, resourceBuffers[RBTYPE_VOXELSCENE], 1, threadID); + device->BindComputePSO(CPSO[CSTYPE_VOXELRADIANCESECONDARYBOUNCE], threadID); + device->Dispatch((UINT)(voxelSceneData.res * voxelSceneData.res * voxelSceneData.res / 64), 1, 1, threadID); + device->EventEnd(threadID); - GetDevice()->EventBegin("Voxel Scene Clear Normals", threadID); - GetDevice()->UnBindResources(1, 1, threadID); - GetDevice()->BindUnorderedAccessResourceCS(resourceBuffers[RBTYPE_VOXELSCENE], 0, threadID); - GetDevice()->BindComputePSO(CPSO[CSTYPE_VOXELCLEARONLYNORMAL], threadID); - GetDevice()->Dispatch((UINT)(voxelSceneData.res * voxelSceneData.res * voxelSceneData.res / 256), 1, 1, threadID); - GetDevice()->EventEnd(threadID); + device->EventBegin("Voxel Scene Clear Normals", threadID); + device->UnbindResources(1, 1, threadID); + device->BindUAV(CS, resourceBuffers[RBTYPE_VOXELSCENE], 0, threadID); + device->BindComputePSO(CPSO[CSTYPE_VOXELCLEARONLYNORMAL], threadID); + device->Dispatch((UINT)(voxelSceneData.res * voxelSceneData.res * voxelSceneData.res / 256), 1, 1, threadID); + device->EventEnd(threadID); result = (Texture3D*)textures[TEXTYPE_3D_VOXELRADIANCE_HELPER]; } - GetDevice()->UnBindUnorderedAccessResources(0, 2, threadID); + device->UnbindUAVs(0, 2, threadID); // Pre-integrate the voxel texture by creating blurred mip levels: - //if (GetDevice()->CheckCapability(GraphicsDevice::GRAPHICSDEVICE_CAPABILITY_UNORDEREDACCESSTEXTURE_LOAD_FORMAT_EXT)) + //if (device->CheckCapability(GraphicsDevice::GRAPHICSDEVICE_CAPABILITY_UNORDEREDACCESSTEXTURE_LOAD_FORMAT_EXT)) //{ // GenerateMipChain(result, MIPGENFILTER_GAUSSIAN, threadID); //} @@ -6003,13 +6006,13 @@ void wiRenderer::VoxelRadiance(GRAPHICSTHREAD threadID) if (voxelHelper) { - GetDevice()->BindResource(VS, result, TEXSLOT_VOXELRADIANCE, threadID); + device->BindResource(VS, result, TEXSLOT_VOXELRADIANCE, threadID); } - GetDevice()->BindResource(PS, result, TEXSLOT_VOXELRADIANCE, threadID); - GetDevice()->BindResource(CS, result, TEXSLOT_VOXELRADIANCE, threadID); + device->BindResource(PS, result, TEXSLOT_VOXELRADIANCE, threadID); + device->BindResource(CS, result, TEXSLOT_VOXELRADIANCE, threadID); wiProfiler::GetInstance().EndRange(threadID); - GetDevice()->EventEnd(threadID); + device->EventEnd(threadID); } @@ -6103,7 +6106,7 @@ void wiRenderer::ComputeTiledLightCulling(bool deferred, GRAPHICSTHREAD threadID GPUResource* uavs[] = { frustumBuffer }; - device->BindUnorderedAccessResourcesCS(uavs, UAVSLOT_TILEFRUSTUMS, ARRAYSIZE(uavs), threadID); + device->BindUAVs(CS, uavs, UAVSLOT_TILEFRUSTUMS, ARRAYSIZE(uavs), threadID); device->BindComputePSO(CPSO[CSTYPE_TILEFRUSTUMS], threadID); DispatchParamsCB dispatchParams; @@ -6117,7 +6120,7 @@ void wiRenderer::ComputeTiledLightCulling(bool deferred, GRAPHICSTHREAD threadID device->BindConstantBuffer(CS, constantBuffers[CBTYPE_DISPATCHPARAMS], CB_GETBINDSLOT(DispatchParamsCB), threadID); device->Dispatch(dispatchParams.numThreadGroups[0], dispatchParams.numThreadGroups[1], dispatchParams.numThreadGroups[2], threadID); - device->UnBindUnorderedAccessResources(UAVSLOT_TILEFRUSTUMS, 1, threadID); + device->UnbindUAVs(UAVSLOT_TILEFRUSTUMS, 1, threadID); device->UAVBarrier(uavs, ARRAYSIZE(uavs), threadID); } @@ -6146,7 +6149,7 @@ void wiRenderer::ComputeTiledLightCulling(bool deferred, GRAPHICSTHREAD threadID { device->EventBegin("Entity Culling", threadID); - device->UnBindResources(SBSLOT_ENTITYINDEXLIST, 1, threadID); + device->UnbindResources(SBSLOT_ENTITYINDEXLIST, 1, threadID); device->BindResource(CS, frustumBuffer, SBSLOT_TILEFRUSTUMS, threadID); @@ -6154,7 +6157,7 @@ void wiRenderer::ComputeTiledLightCulling(bool deferred, GRAPHICSTHREAD threadID if (GetDebugLightCulling()) { - device->BindUnorderedAccessResourceCS(textures[TEXTYPE_2D_DEBUGUAV], UAVSLOT_DEBUGTEXTURE, threadID); + device->BindUAV(CS, textures[TEXTYPE_2D_DEBUGUAV], UAVSLOT_DEBUGTEXTURE, threadID); } @@ -6179,7 +6182,7 @@ void wiRenderer::ComputeTiledLightCulling(bool deferred, GRAPHICSTHREAD threadID resourceBuffers[RBTYPE_ENTITYINDEXLIST_TRANSPARENT], textures[TEXTYPE_2D_TILEDDEFERRED_SPECULARUAV], }; - device->BindUnorderedAccessResourcesCS(uavs, UAVSLOT_TILEDDEFERRED_DIFFUSE, ARRAYSIZE(uavs), threadID); + device->BindUAVs(CS, uavs, UAVSLOT_TILEDDEFERRED_DIFFUSE, ARRAYSIZE(uavs), threadID); GetDevice()->BindResource(CS, Light::shadowMapArray_2D, TEXSLOT_SHADOWARRAY_2D, threadID); GetDevice()->BindResource(CS, Light::shadowMapArray_Cube, TEXSLOT_SHADOWARRAY_CUBE, threadID); @@ -6194,13 +6197,13 @@ void wiRenderer::ComputeTiledLightCulling(bool deferred, GRAPHICSTHREAD threadID resourceBuffers[RBTYPE_ENTITYINDEXLIST_OPAQUE], resourceBuffers[RBTYPE_ENTITYINDEXLIST_TRANSPARENT], }; - device->BindUnorderedAccessResourcesCS(uavs, UAVSLOT_ENTITYINDEXLIST_OPAQUE, ARRAYSIZE(uavs), threadID); + device->BindUAVs(CS, uavs, UAVSLOT_ENTITYINDEXLIST_OPAQUE, ARRAYSIZE(uavs), threadID); device->Dispatch(dispatchParams.numThreadGroups[0], dispatchParams.numThreadGroups[1], dispatchParams.numThreadGroups[2], threadID); device->UAVBarrier(uavs, ARRAYSIZE(uavs), threadID); } - device->UnBindUnorderedAccessResources(0, 8, threadID); // this unbinds pretty much every uav + device->UnbindUAVs(0, 8, threadID); // this unbinds pretty much every uav device->EventEnd(threadID); } @@ -6212,7 +6215,7 @@ void wiRenderer::ResolveMSAADepthBuffer(Texture2D* dst, Texture2D* src, GRAPHICS GetDevice()->EventBegin("Resolve MSAA DepthBuffer", threadID); GetDevice()->BindResource(CS, src, TEXSLOT_ONDEMAND0, threadID); - GetDevice()->BindUnorderedAccessResourceCS(dst, 0, threadID); + GetDevice()->BindUAV(CS, dst, 0, threadID); TextureDesc desc = src->GetDesc(); @@ -6220,8 +6223,8 @@ void wiRenderer::ResolveMSAADepthBuffer(Texture2D* dst, Texture2D* src, GRAPHICS GetDevice()->Dispatch((UINT)ceilf(desc.Width / 16.f), (UINT)ceilf(desc.Height / 16.f), 1, threadID); - GetDevice()->UnBindResources(TEXSLOT_ONDEMAND0, 1, threadID); - GetDevice()->UnBindUnorderedAccessResources(0, 1, threadID); + GetDevice()->UnbindResources(TEXSLOT_ONDEMAND0, 1, threadID); + GetDevice()->UnbindUAVs(0, 1, threadID); GetDevice()->EventEnd(threadID); } @@ -6266,7 +6269,7 @@ void wiRenderer::GenerateMipChain(Texture2D* texture, MIPGENFILTER filter, GRAPH for (UINT i = 0; i < desc.MipLevels - 1; ++i) { - GetDevice()->BindUnorderedAccessResourceCS(texture, 0, threadID, i + 1); + GetDevice()->BindUAV(CS, texture, 0, threadID, i + 1); GetDevice()->BindResource(CS, texture, TEXSLOT_UNIQUE0, threadID, i); desc.Width = max(1, (UINT)ceilf(desc.Width * 0.5f)); desc.Height = max(1, (UINT)ceilf(desc.Height * 0.5f)); @@ -6277,8 +6280,8 @@ void wiRenderer::GenerateMipChain(Texture2D* texture, MIPGENFILTER filter, GRAPH threadID); } - GetDevice()->UnBindResources(TEXSLOT_UNIQUE0, 1, threadID); - GetDevice()->UnBindUnorderedAccessResources(0, 1, threadID); + GetDevice()->UnbindResources(TEXSLOT_UNIQUE0, 1, threadID); + GetDevice()->UnbindUAVs(0, 1, threadID); GetDevice()->EventEnd(threadID); } @@ -6319,7 +6322,7 @@ void wiRenderer::GenerateMipChain(Texture3D* texture, MIPGENFILTER filter, GRAPH for (UINT i = 0; i < desc.MipLevels - 1; ++i) { - GetDevice()->BindUnorderedAccessResourceCS(texture, 0, threadID, i + 1); + GetDevice()->BindUAV(CS, texture, 0, threadID, i + 1); GetDevice()->BindResource(CS, texture, TEXSLOT_UNIQUE0, threadID, i); desc.Width = max(1, (UINT)ceilf(desc.Width * 0.5f)); desc.Height = max(1, (UINT)ceilf(desc.Height * 0.5f)); @@ -6331,8 +6334,8 @@ void wiRenderer::GenerateMipChain(Texture3D* texture, MIPGENFILTER filter, GRAPH threadID); } - GetDevice()->UnBindResources(TEXSLOT_UNIQUE0, 1, threadID); - GetDevice()->UnBindUnorderedAccessResources(0, 1, threadID); + GetDevice()->UnbindResources(TEXSLOT_UNIQUE0, 1, threadID); + GetDevice()->UnbindUAVs(0, 1, threadID); GetDevice()->EventEnd(threadID); } @@ -6374,16 +6377,16 @@ void wiRenderer::CopyTexture2D(Texture2D* dst, UINT DstMIP, UINT DstX, UINT DstY if (DstMIP > 0) { assert(desc_dst.MipLevels > DstMIP); - device->BindUnorderedAccessResourceCS(dst, 0, threadID, DstMIP); + device->BindUAV(CS, dst, 0, threadID, DstMIP); } else { - device->BindUnorderedAccessResourceCS(dst, 0, threadID); + device->BindUAV(CS, dst, 0, threadID); } device->Dispatch((UINT)ceilf((float)cb.xCopySrcSize.x / 8.0f), (UINT)ceilf((float)cb.xCopySrcSize.y / 8.0f), 1, threadID); - device->UnBindUnorderedAccessResources(0, 1, threadID); + device->UnbindUAVs(0, 1, threadID); device->EventEnd(threadID); } @@ -6587,7 +6590,7 @@ void wiRenderer::BuildSceneBVH(GRAPHICSTHREAD threadID) bvhNodeBuffer, bvhAABBBuffer, }; - device->BindUnorderedAccessResourcesCS(uavs, 0, ARRAYSIZE(uavs), threadID); + device->BindUAVs(CS, uavs, 0, ARRAYSIZE(uavs), threadID); device->Dispatch(1, 1, 1, threadID); } @@ -6608,7 +6611,7 @@ void wiRenderer::BuildSceneBVH(GRAPHICSTHREAD threadID) clusterOffsetBuffer, clusterAABBBuffer, }; - device->BindUnorderedAccessResourcesCS(uavs, 0, ARRAYSIZE(uavs), threadID); + device->BindUAVs(CS, uavs, 0, ARRAYSIZE(uavs), threadID); for (auto& model : GetScene().models) { @@ -6647,7 +6650,7 @@ void wiRenderer::BuildSceneBVH(GRAPHICSTHREAD threadID) } device->UAVBarrier(uavs, ARRAYSIZE(uavs), threadID); - device->UnBindUnorderedAccessResources(0, ARRAYSIZE(uavs), threadID); + device->UnbindUAVs(0, ARRAYSIZE(uavs), threadID); } device->EventEnd(threadID); @@ -6662,7 +6665,7 @@ void wiRenderer::BuildSceneBVH(GRAPHICSTHREAD threadID) GPUResource* uavs[] = { indirectBuffer, }; - device->BindUnorderedAccessResourcesCS(uavs, 0, ARRAYSIZE(uavs), threadID); + device->BindUAVs(CS, uavs, 0, ARRAYSIZE(uavs), threadID); GPUResource* res[] = { clusterCounterBuffer, @@ -6672,7 +6675,7 @@ void wiRenderer::BuildSceneBVH(GRAPHICSTHREAD threadID) device->Dispatch(1, 1, 1, threadID); device->UAVBarrier(uavs, ARRAYSIZE(uavs), threadID); - device->UnBindUnorderedAccessResources(0, ARRAYSIZE(uavs), threadID); + device->UnbindUAVs(0, ARRAYSIZE(uavs), threadID); } device->EventEnd(threadID); @@ -6683,7 +6686,7 @@ void wiRenderer::BuildSceneBVH(GRAPHICSTHREAD threadID) clusterSortedMortonBuffer, clusterConeBuffer, }; - device->BindUnorderedAccessResourcesCS(uavs, 0, ARRAYSIZE(uavs), threadID); + device->BindUAVs(CS, uavs, 0, ARRAYSIZE(uavs), threadID); GPUResource* res[] = { clusterCounterBuffer, @@ -6699,7 +6702,7 @@ void wiRenderer::BuildSceneBVH(GRAPHICSTHREAD threadID) device->UAVBarrier(uavs, ARRAYSIZE(uavs), threadID); - device->UnBindUnorderedAccessResources(0, ARRAYSIZE(uavs), threadID); + device->UnbindUAVs(0, ARRAYSIZE(uavs), threadID); } device->EventEnd(threadID); @@ -6710,7 +6713,7 @@ void wiRenderer::BuildSceneBVH(GRAPHICSTHREAD threadID) bvhNodeBuffer, bvhFlagBuffer, }; - device->BindUnorderedAccessResourcesCS(uavs, 0, ARRAYSIZE(uavs), threadID); + device->BindUAVs(CS, uavs, 0, ARRAYSIZE(uavs), threadID); GPUResource* res[] = { clusterCounterBuffer, @@ -6722,7 +6725,7 @@ void wiRenderer::BuildSceneBVH(GRAPHICSTHREAD threadID) device->UAVBarrier(uavs, ARRAYSIZE(uavs), threadID); - device->UnBindUnorderedAccessResources(0, ARRAYSIZE(uavs), threadID); + device->UnbindUAVs(0, ARRAYSIZE(uavs), threadID); } device->EventEnd(threadID); @@ -6733,7 +6736,7 @@ void wiRenderer::BuildSceneBVH(GRAPHICSTHREAD threadID) bvhAABBBuffer, bvhFlagBuffer, }; - device->BindUnorderedAccessResourcesCS(uavs, 0, ARRAYSIZE(uavs), threadID); + device->BindUAVs(CS, uavs, 0, ARRAYSIZE(uavs), threadID); GPUResource* res[] = { clusterCounterBuffer, @@ -6747,7 +6750,7 @@ void wiRenderer::BuildSceneBVH(GRAPHICSTHREAD threadID) device->UAVBarrier(uavs, ARRAYSIZE(uavs), threadID); - device->UnBindUnorderedAccessResources(0, ARRAYSIZE(uavs), threadID); + device->UnbindUAVs(0, ARRAYSIZE(uavs), threadID); } device->EventEnd(threadID); @@ -7070,12 +7073,12 @@ void wiRenderer::DrawTracedScene(Camera* camera, wiGraphicsTypes::Texture2D* res GPUResource* uavs[] = { result, }; - device->BindUnorderedAccessResourcesCS(uavs, 0, ARRAYSIZE(uavs), threadID); + device->BindUAVs(CS, uavs, 0, ARRAYSIZE(uavs), threadID); device->Dispatch((UINT)ceilf((float)_width / (float)TRACEDRENDERING_CLEAR_BLOCKSIZE), (UINT)ceilf((float)_height / (float)TRACEDRENDERING_CLEAR_BLOCKSIZE), 1, threadID); device->UAVBarrier(uavs, ARRAYSIZE(uavs), threadID); - device->UnBindUnorderedAccessResources(0, ARRAYSIZE(uavs), threadID); + device->UnbindUAVs(0, ARRAYSIZE(uavs), threadID); } device->EventEnd(threadID); @@ -7088,12 +7091,12 @@ void wiRenderer::DrawTracedScene(Camera* camera, wiGraphicsTypes::Texture2D* res GPUResource* uavs[] = { rayBuffer[0], }; - device->BindUnorderedAccessResourcesCS(uavs, 0, ARRAYSIZE(uavs), threadID); + device->BindUAVs(CS, uavs, 0, ARRAYSIZE(uavs), threadID); device->Dispatch((UINT)ceilf((float)_width / (float)TRACEDRENDERING_LAUNCH_BLOCKSIZE), (UINT)ceilf((float)_height / (float)TRACEDRENDERING_LAUNCH_BLOCKSIZE), 1, threadID); device->UAVBarrier(uavs, ARRAYSIZE(uavs), threadID); - device->UnBindUnorderedAccessResources(0, ARRAYSIZE(uavs), threadID); + device->UnbindUAVs(0, ARRAYSIZE(uavs), threadID); // just write initial ray count: device->UpdateBuffer(counterBuffer[0], &_raycount, threadID); @@ -7148,12 +7151,12 @@ void wiRenderer::DrawTracedScene(Camera* camera, wiGraphicsTypes::Texture2D* res counterBuffer[__writeBufferID], indirectBuffer, }; - device->BindUnorderedAccessResourcesCS(uavs, 0, ARRAYSIZE(uavs), threadID); + device->BindUAVs(CS, uavs, 0, ARRAYSIZE(uavs), threadID); device->Dispatch(1, 1, 1, threadID); device->UAVBarrier(uavs, ARRAYSIZE(uavs), threadID); - device->UnBindUnorderedAccessResources(0, ARRAYSIZE(uavs), threadID); + device->UnbindUAVs(0, ARRAYSIZE(uavs), threadID); } device->EventEnd(threadID); @@ -7178,12 +7181,12 @@ void wiRenderer::DrawTracedScene(Camera* camera, wiGraphicsTypes::Texture2D* res GPUResource* uavs[] = { result, }; - device->BindUnorderedAccessResourcesCS(uavs, 0, ARRAYSIZE(uavs), threadID); + device->BindUAVs(CS, uavs, 0, ARRAYSIZE(uavs), threadID); device->DispatchIndirect(indirectBuffer, 0, threadID); device->UAVBarrier(uavs, ARRAYSIZE(uavs), threadID); - device->UnBindUnorderedAccessResources(0, ARRAYSIZE(uavs), threadID); + device->UnbindUAVs(0, ARRAYSIZE(uavs), threadID); } device->EventEnd(threadID); @@ -7214,12 +7217,12 @@ void wiRenderer::DrawTracedScene(Camera* camera, wiGraphicsTypes::Texture2D* res rayBuffer[__writeBufferID], result, }; - device->BindUnorderedAccessResourcesCS(uavs, 0, ARRAYSIZE(uavs), threadID); + device->BindUAVs(CS, uavs, 0, ARRAYSIZE(uavs), threadID); device->DispatchIndirect(indirectBuffer, 0, threadID); device->UAVBarrier(uavs, ARRAYSIZE(uavs), threadID); - device->UnBindUnorderedAccessResources(0, ARRAYSIZE(uavs), threadID); + device->UnbindUAVs(0, ARRAYSIZE(uavs), threadID); } device->EventEnd(threadID); @@ -7248,7 +7251,7 @@ void wiRenderer::GenerateClouds(Texture2D* dst, UINT refinementCount, float rand assert(dst_desc.BindFlags & BIND_UNORDERED_ACCESS); GetDevice()->BindResource(CS, wiTextureHelper::getInstance()->getRandom64x64(), TEXSLOT_ONDEMAND0, threadID); - GetDevice()->BindUnorderedAccessResourceCS(dst, 0, threadID); + GetDevice()->BindUAV(CS, dst, 0, threadID); CloudGeneratorCB cb; cb.xNoiseTexDim = XMFLOAT2((float)src_desc.Width, (float)src_desc.Height); @@ -7267,8 +7270,8 @@ void wiRenderer::GenerateClouds(Texture2D* dst, UINT refinementCount, float rand GetDevice()->BindComputePSO(CPSO[CSTYPE_CLOUDGENERATOR], threadID); GetDevice()->Dispatch((UINT)ceilf(dst_desc.Width / (float)CLOUDGENERATOR_BLOCKSIZE), (UINT)ceilf(dst_desc.Height / (float)CLOUDGENERATOR_BLOCKSIZE), 1, threadID); - GetDevice()->UnBindResources(TEXSLOT_ONDEMAND0, 1, threadID); - GetDevice()->UnBindUnorderedAccessResources(0, 1, threadID); + GetDevice()->UnbindResources(TEXSLOT_ONDEMAND0, 1, threadID); + GetDevice()->UnbindUAVs(0, 1, threadID); GetDevice()->EventEnd(threadID); @@ -7667,7 +7670,7 @@ Texture2D* wiRenderer::GetLuminance(Texture2D* sourceImage, GRAPHICSTHREAD threa TextureDesc luminance_map_desc = luminance_map->GetDesc(); device->BindComputePSO(CPSO[CSTYPE_LUMINANCE_PASS1], threadID); device->BindResource(CS, sourceImage, TEXSLOT_ONDEMAND0, threadID); - device->BindUnorderedAccessResourceCS(luminance_map, 0, threadID); + device->BindUAV(CS, luminance_map, 0, threadID); device->Dispatch(luminance_map_desc.Width/16, luminance_map_desc.Height/16, 1, threadID); // Pass 2 : Reduce for average luminance until we got an 1x1 texture @@ -7676,7 +7679,7 @@ Texture2D* wiRenderer::GetLuminance(Texture2D* sourceImage, GRAPHICSTHREAD threa { luminance_avg_desc = luminance_avg[i]->GetDesc(); device->BindComputePSO(CPSO[CSTYPE_LUMINANCE_PASS2], threadID); - device->BindUnorderedAccessResourceCS(luminance_avg[i], 0, threadID); + device->BindUAV(CS, luminance_avg[i], 0, threadID); if (i > 0) { device->BindResource(CS, luminance_avg[i-1], TEXSLOT_ONDEMAND0, threadID); @@ -7689,7 +7692,7 @@ Texture2D* wiRenderer::GetLuminance(Texture2D* sourceImage, GRAPHICSTHREAD threa } - device->UnBindUnorderedAccessResources(0, 1, threadID); + device->UnbindUAVs(0, 1, threadID); return luminance_avg.back(); } diff --git a/WickedEngine/wiVersion.cpp b/WickedEngine/wiVersion.cpp index bf401d2f6..1769ab215 100644 --- a/WickedEngine/wiVersion.cpp +++ b/WickedEngine/wiVersion.cpp @@ -9,7 +9,7 @@ namespace wiVersion // minor features, major updates const int minor = 18; // minor bug fixes, alterations, refactors, updates - const int revision = 7; + const int revision = 8; long GetVersion() diff --git a/WickedEngine/wiWidget.cpp b/WickedEngine/wiWidget.cpp index f019af8f9..20817b056 100644 --- a/WickedEngine/wiWidget.cpp +++ b/WickedEngine/wiWidget.cpp @@ -356,7 +356,7 @@ void wiButton::Render(wiGUI* gui) scissorRect.left = (LONG)(translation.x); scissorRect.right = (LONG)(translation.x + scale.x); scissorRect.top = (LONG)(translation.y); - wiRenderer::GetDevice()->SetScissorRects(1, &scissorRect, gui->GetGraphicsThread()); + wiRenderer::GetDevice()->BindScissorRects(1, &scissorRect, gui->GetGraphicsThread()); wiFont(text, wiFontProps((int)(translation.x + scale.x*0.5f), (int)(translation.y + scale.y*0.5f), -1, WIFALIGN_CENTER, WIFALIGN_CENTER, 2, 1, textColor, textShadowColor)).Draw(gui->GetGraphicsThread()); @@ -426,7 +426,7 @@ void wiLabel::Render(wiGUI* gui) scissorRect.left = (LONG)(translation.x); scissorRect.right = (LONG)(translation.x + scale.x); scissorRect.top = (LONG)(translation.y); - wiRenderer::GetDevice()->SetScissorRects(1, &scissorRect, gui->GetGraphicsThread()); + wiRenderer::GetDevice()->BindScissorRects(1, &scissorRect, gui->GetGraphicsThread()); wiFont(text, wiFontProps((int)translation.x + 2, (int)translation.y + 2, -1, WIFALIGN_LEFT, WIFALIGN_TOP, 2, 1, textColor, textShadowColor)).Draw(gui->GetGraphicsThread()); @@ -583,7 +583,7 @@ void wiTextInputField::Render(wiGUI* gui) scissorRect.left = (LONG)(translation.x); scissorRect.right = (LONG)(translation.x + scale.x); scissorRect.top = (LONG)(translation.y); - wiRenderer::GetDevice()->SetScissorRects(1, &scissorRect, gui->GetGraphicsThread()); + wiRenderer::GetDevice()->BindScissorRects(1, &scissorRect, gui->GetGraphicsThread()); string activeText = text; if (state == ACTIVE) @@ -771,7 +771,7 @@ void wiSlider::Render(wiGUI* gui) if (parent != nullptr) { - wiRenderer::GetDevice()->SetScissorRects(1, &scissorRect, gui->GetGraphicsThread()); + wiRenderer::GetDevice()->BindScissorRects(1, &scissorRect, gui->GetGraphicsThread()); } // text wiFont(text, wiFontProps((int)(translation.x - headWidth * 0.5f), (int)(translation.y + scale.y*0.5f), -1, WIFALIGN_RIGHT, WIFALIGN_CENTER, 2, 1, @@ -908,7 +908,7 @@ void wiCheckBox::Render(wiGUI* gui) if (parent != nullptr) { - wiRenderer::GetDevice()->SetScissorRects(1, &scissorRect, gui->GetGraphicsThread()); + wiRenderer::GetDevice()->BindScissorRects(1, &scissorRect, gui->GetGraphicsThread()); } wiFont(text, wiFontProps((int)(translation.x), (int)(translation.y + scale.y*0.5f), -1, WIFALIGN_RIGHT, WIFALIGN_CENTER, 2, 1, textColor, textShadowColor )).Draw(gui->GetGraphicsThread()); @@ -1096,7 +1096,7 @@ void wiComboBox::Render(wiGUI* gui) if (parent != nullptr) { - wiRenderer::GetDevice()->SetScissorRects(1, &scissorRect, gui->GetGraphicsThread()); + wiRenderer::GetDevice()->BindScissorRects(1, &scissorRect, gui->GetGraphicsThread()); } wiFont(text, wiFontProps((int)(translation.x), (int)(translation.y + scale.y*0.5f), -1, WIFALIGN_RIGHT, WIFALIGN_CENTER, 2, 1, textColor, textShadowColor)).Draw(gui->GetGraphicsThread()); @@ -1418,7 +1418,7 @@ void wiWindow::Render(wiGUI* gui) scissorRect.left = (LONG)(translation.x); scissorRect.right = (LONG)(translation.x + scale.x); scissorRect.top = (LONG)(translation.y); - wiRenderer::GetDevice()->SetScissorRects(1, &scissorRect, gui->GetGraphicsThread()); + wiRenderer::GetDevice()->BindScissorRects(1, &scissorRect, gui->GetGraphicsThread()); wiFont(text, wiFontProps((int)(translation.x + resizeDragger_UpperLeft->scale.x + 2), (int)(translation.y), -1, WIFALIGN_LEFT, WIFALIGN_TOP, 2, 1, textColor, textShadowColor)).Draw(gui->GetGraphicsThread());