added CmdClearTextureUAV

This commit is contained in:
myT 2023-12-18 00:52:11 +01:00
parent 455408faa6
commit 55f227771e
2 changed files with 19 additions and 0 deletions

View file

@ -4405,6 +4405,24 @@ namespace RHI
rhi.commandList->ClearDepthStencilView(dsvHandle, flags, depth, stencil, rectCount, d3dRectPtr);
}
void CmdClearTextureUAV(HTexture htexture, HDescriptorTable hdescTable, uint32_t tableIndex, uint32_t mipIndex, const uint32_t* values)
{
Q_assert(CanWriteCommands());
Q_assert(values);
static_assert(sizeof(UINT) == 4, "sizeof(UINT) isn't 4 as expected");
const Texture& texture = rhi.textures.Get(htexture);
Q_assert(mipIndex < texture.desc.mipCount);
const uint32_t cpuDescIndex = texture.mips[mipIndex].uavIndex;
const D3D12_CPU_DESCRIPTOR_HANDLE cpuHandle = rhi.descHeapGeneric.GetCPUHandle(cpuDescIndex);
const DescriptorTable& descTable = rhi.descriptorTables.Get(hdescTable);
D3D12_GPU_DESCRIPTOR_HANDLE gpuHandle = descTable.genericHeap->GetGPUDescriptorHandleForHeapStart();
const uint32_t gpuDescIndex = tableIndex;
gpuHandle.ptr += gpuDescIndex * rhi.device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
rhi.commandList->ClearUnorderedAccessViewUint(gpuHandle, cpuHandle, texture.texture, values, 0, NULL);
}
void CmdInsertDebugLabel(const char* name, float r, float g, float b)
{
Q_assert(CanWriteCommands());

View file

@ -729,6 +729,7 @@ namespace RHI
void CmdBarrier(uint32_t texCount, const TextureBarrier* textures, uint32_t buffCount = 0, const BufferBarrier* buffers = NULL);
void CmdClearColorTarget(HTexture texture, const vec4_t clearColor, const Rect* rect = NULL);
void CmdClearDepthStencilTarget(HTexture texture, bool clearDepth, float depth, bool clearStencil = false, uint8_t stencil = 0, const Rect* rect = NULL);
void CmdClearTextureUAV(HTexture texture, HDescriptorTable descTable, uint32_t tableIndex, uint32_t mipIndex, const uint32_t* values);
void CmdInsertDebugLabel(const char* name, float r = 1.0f, float g = 1.0f, float b = 1.0f);
void CmdBeginDebugLabel(const char* name, float r = 1.0f, float g = 1.0f, float b = 1.0f);
void CmdEndDebugLabel();