summaryrefslogtreecommitdiffstats
path: root/tools/gfx
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2021-12-13 09:57:56 -0800
committerGitHub <noreply@github.com>2021-12-13 09:57:56 -0800
commit3359313620cd57b8404f95cfe7b07cce514eff71 (patch)
tree8f7edee5b23ca0345ce7ac62b54a9726c84752bf /tools/gfx
parentc1064a263350ee6042625bf368a97f7fe94dcd39 (diff)
gfx: use uint32_t in draw calls and implement current size query. (#2055)
* gfx: Implement remaining resource commands on D3D12. Includes: `textureBarrier`, `copyTexture`, `uploadTextureData`, `copyTextureToBuffer`, and `textureSubresourceBarrier`. * gfx: Implement `CurrentSize` query. Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'tools/gfx')
-rw-r--r--tools/gfx/command-writer.h16
-rw-r--r--tools/gfx/d3d11/render-d3d11.cpp33
-rw-r--r--tools/gfx/d3d12/render-d3d12.cpp46
-rw-r--r--tools/gfx/debug-layer.cpp22
-rw-r--r--tools/gfx/debug-layer.h23
-rw-r--r--tools/gfx/immediate-renderer-base.cpp35
-rw-r--r--tools/gfx/immediate-renderer-base.h32
-rw-r--r--tools/gfx/open-gl/render-gl.cpp30
-rw-r--r--tools/gfx/vulkan/render-vk.cpp60
9 files changed, 171 insertions, 126 deletions
diff --git a/tools/gfx/command-writer.h b/tools/gfx/command-writer.h
index 04be1be86..208cb185a 100644
--- a/tools/gfx/command-writer.h
+++ b/tools/gfx/command-writer.h
@@ -195,11 +195,11 @@ public:
}
void setVertexBuffers(
- UInt startSlot,
- UInt slotCount,
+ uint32_t startSlot,
+ uint32_t slotCount,
IBufferResource* const* buffers,
- const UInt* strides,
- const UInt* offsets)
+ const uint32_t* strides,
+ const uint32_t* offsets)
{
uint32_t bufferOffset = 0;
for (UInt i = 0; i < slotCount; i++)
@@ -208,12 +208,12 @@ public:
if (i == 0)
bufferOffset = offset;
}
- uint32_t stridesOffset = encodeData(strides, sizeof(UInt) * slotCount);
- uint32_t offsetsOffset = encodeData(offsets, sizeof(UInt) * slotCount);
+ uint32_t stridesOffset = encodeData(strides, sizeof(uint32_t) * slotCount);
+ uint32_t offsetsOffset = encodeData(offsets, sizeof(uint32_t) * slotCount);
m_commands.add(Command(
CommandName::SetVertexBuffers,
- (uint32_t)startSlot,
- (uint32_t)slotCount,
+ startSlot,
+ slotCount,
bufferOffset,
stridesOffset,
offsetsOffset));
diff --git a/tools/gfx/d3d11/render-d3d11.cpp b/tools/gfx/d3d11/render-d3d11.cpp
index 78cd5b61a..cb6d62830 100644
--- a/tools/gfx/d3d11/render-d3d11.cpp
+++ b/tools/gfx/d3d11/render-d3d11.cpp
@@ -135,17 +135,19 @@ public:
virtual void setPrimitiveTopology(PrimitiveTopology topology) override;
virtual void setVertexBuffers(
- UInt startSlot,
- UInt slotCount,
+ uint32_t startSlot,
+ uint32_t slotCount,
IBufferResource* const* buffers,
- const UInt* strides,
- const UInt* offsets) override;
- virtual void setIndexBuffer(IBufferResource* buffer, Format indexFormat, UInt offset) override;
+ const uint32_t* strides,
+ const uint32_t* offsets) override;
+ virtual void setIndexBuffer(
+ IBufferResource* buffer, Format indexFormat, uint32_t offset) override;
virtual void setViewports(UInt count, Viewport const* viewports) override;
virtual void setScissorRects(UInt count, ScissorRect const* rects) override;
virtual void setPipelineState(IPipelineState* state) override;
- virtual void draw(UInt vertexCount, UInt startVertex) override;
- virtual void drawIndexed(UInt indexCount, UInt startIndex, UInt baseVertex) override;
+ virtual void draw(uint32_t vertexCount, uint32_t startVertex) override;
+ virtual void drawIndexed(
+ uint32_t indexCount, uint32_t startIndex, uint32_t baseVertex) override;
virtual void dispatchCompute(int x, int y, int z) override;
virtual void submitGpuWork() override {}
virtual void waitForGpu() override
@@ -3241,7 +3243,12 @@ void D3D11Device::setPrimitiveTopology(PrimitiveTopology topology)
m_immediateContext->IASetPrimitiveTopology(D3DUtil::getPrimitiveTopology(topology));
}
-void D3D11Device::setVertexBuffers(UInt startSlot, UInt slotCount, IBufferResource*const* buffersIn, const UInt* stridesIn, const UInt* offsetsIn)
+void D3D11Device::setVertexBuffers(
+ uint32_t startSlot,
+ uint32_t slotCount,
+ IBufferResource* const* buffersIn,
+ const uint32_t* stridesIn,
+ const uint32_t* offsetsIn)
{
static const int kMaxVertexBuffers = 16;
assert(slotCount <= kMaxVertexBuffers);
@@ -3262,7 +3269,7 @@ void D3D11Device::setVertexBuffers(UInt startSlot, UInt slotCount, IBufferResour
m_immediateContext->IASetVertexBuffers((UINT)startSlot, (UINT)slotCount, dxBuffers, &vertexStrides[0], &vertexOffsets[0]);
}
-void D3D11Device::setIndexBuffer(IBufferResource* buffer, Format indexFormat, UInt offset)
+void D3D11Device::setIndexBuffer(IBufferResource* buffer, Format indexFormat, uint32_t offset)
{
DXGI_FORMAT dxFormat = D3DUtil::getMapFormat(indexFormat);
m_immediateContext->IASetIndexBuffer(((BufferResourceImpl*)buffer)->m_buffer, dxFormat, UINT(offset));
@@ -3382,16 +3389,16 @@ void D3D11Device::setPipelineState(IPipelineState* state)
/// ...
}
-void D3D11Device::draw(UInt vertexCount, UInt startVertex)
+void D3D11Device::draw(uint32_t vertexCount, uint32_t startVertex)
{
_flushGraphicsState();
- m_immediateContext->Draw((UINT)vertexCount, (UINT)startVertex);
+ m_immediateContext->Draw(vertexCount, startVertex);
}
-void D3D11Device::drawIndexed(UInt indexCount, UInt startIndex, UInt baseVertex)
+void D3D11Device::drawIndexed(uint32_t indexCount, uint32_t startIndex, uint32_t baseVertex)
{
_flushGraphicsState();
- m_immediateContext->DrawIndexed((UINT)indexCount, (UINT)startIndex, (INT)baseVertex);
+ m_immediateContext->DrawIndexed(indexCount, startIndex, baseVertex);
}
Result D3D11Device::createProgram(const IShaderProgram::Desc& desc, IShaderProgram** outProgram)
diff --git a/tools/gfx/d3d12/render-d3d12.cpp b/tools/gfx/d3d12/render-d3d12.cpp
index b9b8c6c57..68a5b3e50 100644
--- a/tools/gfx/d3d12/render-d3d12.cpp
+++ b/tools/gfx/d3d12/render-d3d12.cpp
@@ -3265,11 +3265,11 @@ public:
}
virtual SLANG_NO_THROW void SLANG_MCALL setVertexBuffers(
- UInt startSlot,
- UInt slotCount,
+ uint32_t startSlot,
+ uint32_t slotCount,
IBufferResource* const* buffers,
- const UInt* strides,
- const UInt* offsets) override
+ const uint32_t* strides,
+ const uint32_t* offsets) override
{
{
const Index num = startSlot + slotCount;
@@ -3291,13 +3291,11 @@ public:
}
virtual SLANG_NO_THROW void SLANG_MCALL setIndexBuffer(
- IBufferResource* buffer,
- Format indexFormat,
- UInt offset = 0) override
+ IBufferResource* buffer, Format indexFormat, uint32_t offset = 0) override
{
m_boundIndexBuffer = (BufferResourceImpl*)buffer;
m_boundIndexFormat = D3DUtil::getMapFormat(indexFormat);
- m_boundIndexOffset = UINT(offset);
+ m_boundIndexOffset = offset;
}
void prepareDraw()
@@ -3357,17 +3355,16 @@ public:
}
}
virtual SLANG_NO_THROW void SLANG_MCALL
- draw(UInt vertexCount, UInt startVertex = 0) override
+ draw(uint32_t vertexCount, uint32_t startVertex = 0) override
{
prepareDraw();
- m_d3dCmdList->DrawInstanced(UINT(vertexCount), 1, UINT(startVertex), 0);
+ m_d3dCmdList->DrawInstanced(vertexCount, 1, startVertex, 0);
}
- virtual SLANG_NO_THROW void SLANG_MCALL
- drawIndexed(UInt indexCount, UInt startIndex = 0, UInt baseVertex = 0) override
+ virtual SLANG_NO_THROW void SLANG_MCALL drawIndexed(
+ uint32_t indexCount, uint32_t startIndex = 0, uint32_t baseVertex = 0) override
{
prepareDraw();
- m_d3dCmdList->DrawIndexedInstanced(
- (UINT)indexCount, 1, (UINT)startIndex, (UINT)baseVertex, 0);
+ m_d3dCmdList->DrawIndexedInstanced(indexCount, 1, startIndex, baseVertex, 0);
}
virtual SLANG_NO_THROW void SLANG_MCALL endEncoding() override
{
@@ -3493,13 +3490,14 @@ public:
}
virtual SLANG_NO_THROW void SLANG_MCALL drawInstanced(
- UInt vertexCount,
- UInt instanceCount,
- UInt startVertex,
- UInt startInstanceLocation) override
+ uint32_t vertexCount,
+ uint32_t instanceCount,
+ uint32_t startVertex,
+ uint32_t startInstanceLocation) override
{
prepareDraw();
- m_d3dCmdList->DrawInstanced(vertexCount, instanceCount, startVertex, startInstanceLocation);
+ m_d3dCmdList->DrawInstanced(
+ vertexCount, instanceCount, startVertex, startInstanceLocation);
}
virtual SLANG_NO_THROW void SLANG_MCALL drawIndexedInstanced(
@@ -6696,6 +6694,7 @@ Result D3D12Device::createQueryPool(const IQueryPool::Desc& desc, IQueryPool** o
{
case QueryType::AccelerationStructureCompactedSize:
case QueryType::AccelerationStructureSerializedSize:
+ case QueryType::AccelerationStructureCurrentSize:
{
RefPtr<PlainBufferProxyQueryPoolImpl> queryPoolImpl =
new PlainBufferProxyQueryPoolImpl();
@@ -6824,6 +6823,15 @@ void translatePostBuildInfoDescs(
sizeof(D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_COMPACTED_SIZE_DESC) *
queryDescs[i].firstQueryIndex;
break;
+ case QueryType::AccelerationStructureCurrentSize:
+ postBuildInfoDescs[i].InfoType =
+ D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_CURRENT_SIZE;
+ postBuildInfoDescs[i].DestBuffer =
+ static_cast<D3D12Device::PlainBufferProxyQueryPoolImpl*>(queryDescs[i].queryPool)
+ ->m_bufferResource->getDeviceAddress() +
+ sizeof(D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_COMPACTED_SIZE_DESC) *
+ queryDescs[i].firstQueryIndex;
+ break;
case QueryType::AccelerationStructureSerializedSize:
postBuildInfoDescs[i].InfoType =
D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_SERIALIZATION;
diff --git a/tools/gfx/debug-layer.cpp b/tools/gfx/debug-layer.cpp
index d96af7069..fa7064b89 100644
--- a/tools/gfx/debug-layer.cpp
+++ b/tools/gfx/debug-layer.cpp
@@ -1084,11 +1084,11 @@ void DebugRenderCommandEncoder::setPrimitiveTopology(PrimitiveTopology topology)
}
void DebugRenderCommandEncoder::setVertexBuffers(
- UInt startSlot,
- UInt slotCount,
+ uint32_t startSlot,
+ uint32_t slotCount,
IBufferResource* const* buffers,
- const UInt* strides,
- const UInt* offsets)
+ const uint32_t* strides,
+ const uint32_t* offsets)
{
SLANG_GFX_API_FUNC;
@@ -1101,22 +1101,21 @@ void DebugRenderCommandEncoder::setVertexBuffers(
}
void DebugRenderCommandEncoder::setIndexBuffer(
- IBufferResource* buffer,
- Format indexFormat,
- UInt offset)
+ IBufferResource* buffer, Format indexFormat, uint32_t offset)
{
SLANG_GFX_API_FUNC;
auto innerBuffer = static_cast<DebugBufferResource*>(buffer)->baseObject.get();
baseObject->setIndexBuffer(innerBuffer, indexFormat, offset);
}
-void DebugRenderCommandEncoder::draw(UInt vertexCount, UInt startVertex)
+void DebugRenderCommandEncoder::draw(uint32_t vertexCount, uint32_t startVertex)
{
SLANG_GFX_API_FUNC;
baseObject->draw(vertexCount, startVertex);
}
-void DebugRenderCommandEncoder::drawIndexed(UInt indexCount, UInt startIndex, UInt baseVertex)
+void DebugRenderCommandEncoder::drawIndexed(
+ uint32_t indexCount, uint32_t startIndex, uint32_t baseVertex)
{
SLANG_GFX_API_FUNC;
baseObject->drawIndexed(indexCount, startIndex, baseVertex);
@@ -1166,7 +1165,10 @@ Result DebugRenderCommandEncoder::setSamplePositions(
}
void DebugRenderCommandEncoder::drawInstanced(
- UInt vertexCount, UInt instanceCount, UInt startVertex, UInt startInstanceLocation)
+ uint32_t vertexCount,
+ uint32_t instanceCount,
+ uint32_t startVertex,
+ uint32_t startInstanceLocation)
{
SLANG_GFX_API_FUNC;
return baseObject->drawInstanced(
diff --git a/tools/gfx/debug-layer.h b/tools/gfx/debug-layer.h
index 07182d70d..df38fa512 100644
--- a/tools/gfx/debug-layer.h
+++ b/tools/gfx/debug-layer.h
@@ -345,16 +345,17 @@ public:
virtual SLANG_NO_THROW void SLANG_MCALL
setPrimitiveTopology(PrimitiveTopology topology) override;
virtual SLANG_NO_THROW void SLANG_MCALL setVertexBuffers(
- UInt startSlot,
- UInt slotCount,
+ uint32_t startSlot,
+ uint32_t slotCount,
IBufferResource* const* buffers,
- const UInt* strides,
- const UInt* offsets) override;
+ const uint32_t* strides,
+ const uint32_t* offsets) override;
virtual SLANG_NO_THROW void SLANG_MCALL
- setIndexBuffer(IBufferResource* buffer, Format indexFormat, UInt offset = 0) override;
- virtual SLANG_NO_THROW void SLANG_MCALL draw(UInt vertexCount, UInt startVertex = 0) override;
+ setIndexBuffer(IBufferResource* buffer, Format indexFormat, uint32_t offset = 0) override;
virtual SLANG_NO_THROW void SLANG_MCALL
- drawIndexed(UInt indexCount, UInt startIndex = 0, UInt baseVertex = 0) override;
+ draw(uint32_t vertexCount, uint32_t startVertex = 0) override;
+ virtual SLANG_NO_THROW void SLANG_MCALL
+ drawIndexed(uint32_t indexCount, uint32_t startIndex = 0, uint32_t baseVertex = 0) override;
virtual SLANG_NO_THROW void SLANG_MCALL drawIndirect(
uint32_t maxDrawCount,
IBufferResource* argBuffer,
@@ -374,10 +375,10 @@ public:
uint32_t pixelCount,
const SamplePosition* samplePositions) override;
virtual SLANG_NO_THROW void SLANG_MCALL drawInstanced(
- UInt vertexCount,
- UInt instanceCount,
- UInt startVertex,
- UInt startInstanceLocation) override;
+ uint32_t vertexCount,
+ uint32_t instanceCount,
+ uint32_t startVertex,
+ uint32_t startInstanceLocation) override;
virtual SLANG_NO_THROW void SLANG_MCALL drawIndexedInstanced(
uint32_t indexCount,
diff --git a/tools/gfx/immediate-renderer-base.cpp b/tools/gfx/immediate-renderer-base.cpp
index df46cc200..f302a1d89 100644
--- a/tools/gfx/immediate-renderer-base.cpp
+++ b/tools/gfx/immediate-renderer-base.cpp
@@ -116,29 +116,30 @@ public:
m_writer->setPrimitiveTopology(topology);
}
virtual SLANG_NO_THROW void SLANG_MCALL setVertexBuffers(
- UInt startSlot,
- UInt slotCount,
+ uint32_t startSlot,
+ uint32_t slotCount,
IBufferResource* const* buffers,
- const UInt* strides,
- const UInt* offsets) override
+ const uint32_t* strides,
+ const uint32_t* offsets) override
{
m_writer->setVertexBuffers(startSlot, slotCount, buffers, strides, offsets);
}
virtual SLANG_NO_THROW void SLANG_MCALL
- setIndexBuffer(IBufferResource* buffer, Format indexFormat, UInt offset) override
+ setIndexBuffer(IBufferResource* buffer, Format indexFormat, uint32_t offset) override
{
m_writer->setIndexBuffer(buffer, indexFormat, offset);
}
- virtual SLANG_NO_THROW void SLANG_MCALL draw(UInt vertexCount, UInt startVertex) override
+ virtual SLANG_NO_THROW void SLANG_MCALL
+ draw(uint32_t vertexCount, uint32_t startVertex) override
{
m_writer->bindRootShaderObject(m_commandBuffer->m_rootShaderObject);
m_writer->draw(vertexCount, startVertex);
}
virtual SLANG_NO_THROW void SLANG_MCALL
- drawIndexed(UInt indexCount, UInt startIndex, UInt baseVertex) override
+ drawIndexed(uint32_t indexCount, uint32_t startIndex, uint32_t baseVertex) override
{
m_writer->bindRootShaderObject(m_commandBuffer->m_rootShaderObject);
m_writer->drawIndexed(indexCount, startIndex, baseVertex);
@@ -196,10 +197,10 @@ public:
}
virtual SLANG_NO_THROW void SLANG_MCALL drawInstanced(
- UInt vertexCount,
- UInt instanceCount,
- UInt startVertex,
- UInt startInstanceLocation) override
+ uint32_t vertexCount,
+ uint32_t instanceCount,
+ uint32_t startVertex,
+ uint32_t startInstanceLocation) override
{
SLANG_UNUSED(vertexCount);
SLANG_UNUSED(instanceCount);
@@ -496,11 +497,11 @@ public:
m_writer.getObject<BufferResource>(cmd.operands[2] + i));
}
m_renderer->setVertexBuffers(
- (UInt)cmd.operands[0],
- (UInt)cmd.operands[1],
+ cmd.operands[0],
+ cmd.operands[1],
bufferResources.getArrayView().getBuffer(),
- m_writer.getData<UInt>(cmd.operands[3]),
- m_writer.getData<UInt>(cmd.operands[4]));
+ m_writer.getData<uint32_t>(cmd.operands[3]),
+ m_writer.getData<uint32_t>(cmd.operands[4]));
}
break;
case CommandName::SetIndexBuffer:
@@ -510,11 +511,11 @@ public:
(UInt)cmd.operands[2]);
break;
case CommandName::Draw:
- m_renderer->draw((UInt)cmd.operands[0], (UInt)cmd.operands[1]);
+ m_renderer->draw(cmd.operands[0], cmd.operands[1]);
break;
case CommandName::DrawIndexed:
m_renderer->drawIndexed(
- (UInt)cmd.operands[0], (UInt)cmd.operands[1], (UInt)cmd.operands[2]);
+ cmd.operands[0], cmd.operands[1], cmd.operands[2]);
break;
case CommandName::SetStencilReference:
m_renderer->setStencilReference(cmd.operands[0]);
diff --git a/tools/gfx/immediate-renderer-base.h b/tools/gfx/immediate-renderer-base.h
index b1e867edc..19186d0f2 100644
--- a/tools/gfx/immediate-renderer-base.h
+++ b/tools/gfx/immediate-renderer-base.h
@@ -60,14 +60,16 @@ public:
virtual void setScissorRects(UInt count, const ScissorRect* scissors) = 0;
virtual void setPrimitiveTopology(PrimitiveTopology topology) = 0;
virtual void setVertexBuffers(
- UInt startSlot,
- UInt slotCount,
+ uint32_t startSlot,
+ uint32_t slotCount,
IBufferResource* const* buffers,
- const UInt* strides,
- const UInt* offsets) = 0;
- virtual void setIndexBuffer(IBufferResource* buffer, Format indexFormat, UInt offset = 0) = 0;
- virtual void draw(UInt vertexCount, UInt startVertex = 0) = 0;
- virtual void drawIndexed(UInt indexCount, UInt startIndex = 0, UInt baseVertex = 0) = 0;
+ const uint32_t* strides,
+ const uint32_t* offsets) = 0;
+ virtual void setIndexBuffer(
+ IBufferResource* buffer, Format indexFormat, uint32_t offset = 0) = 0;
+ virtual void draw(uint32_t vertexCount, uint32_t startVertex = 0) = 0;
+ virtual void drawIndexed(
+ uint32_t indexCount, uint32_t startIndex = 0, uint32_t baseVertex = 0) = 0;
virtual void setStencilReference(uint32_t referenceValue) = 0;
virtual void dispatchCompute(int x, int y, int z) = 0;
virtual void copyBuffer(
@@ -137,11 +139,11 @@ public:
SLANG_UNUSED(topology);
}
virtual void setVertexBuffers(
- UInt startSlot,
- UInt slotCount,
+ uint32_t startSlot,
+ uint32_t slotCount,
IBufferResource* const* buffers,
- const UInt* strides,
- const UInt* offsets) override
+ const uint32_t* strides,
+ const uint32_t* offsets) override
{
SLANG_UNUSED(startSlot);
SLANG_UNUSED(slotCount);
@@ -149,19 +151,21 @@ public:
SLANG_UNUSED(strides);
SLANG_UNUSED(offsets);
}
- virtual void setIndexBuffer(IBufferResource* buffer, Format indexFormat, UInt offset = 0)
+ virtual void setIndexBuffer(
+ IBufferResource* buffer, Format indexFormat, uint32_t offset = 0)
override
{
SLANG_UNUSED(buffer);
SLANG_UNUSED(indexFormat);
SLANG_UNUSED(offset);
}
- virtual void draw(UInt vertexCount, UInt startVertex = 0) override
+ virtual void draw(uint32_t vertexCount, uint32_t startVertex = 0) override
{
SLANG_UNUSED(vertexCount);
SLANG_UNUSED(startVertex);
}
- virtual void drawIndexed(UInt indexCount, UInt startIndex = 0, UInt baseVertex = 0) override
+ virtual void drawIndexed(
+ uint32_t indexCount, uint32_t startIndex = 0, uint32_t baseVertex = 0) override
{
SLANG_UNUSED(indexCount);
SLANG_UNUSED(startIndex);
diff --git a/tools/gfx/open-gl/render-gl.cpp b/tools/gfx/open-gl/render-gl.cpp
index e007232d9..8e59356da 100644
--- a/tools/gfx/open-gl/render-gl.cpp
+++ b/tools/gfx/open-gl/render-gl.cpp
@@ -166,17 +166,19 @@ public:
virtual void setPrimitiveTopology(PrimitiveTopology topology) override;
virtual void setVertexBuffers(
- UInt startSlot,
- UInt slotCount,
+ uint32_t startSlot,
+ uint32_t slotCount,
IBufferResource* const* buffers,
- const UInt* strides,
- const UInt* offsets) override;
- virtual void setIndexBuffer(IBufferResource* buffer, Format indexFormat, UInt offset) override;
+ const uint32_t* strides,
+ const uint32_t* offsets) override;
+ virtual void setIndexBuffer(
+ IBufferResource* buffer, Format indexFormat, uint32_t offset) override;
virtual void setViewports(UInt count, Viewport const* viewports) override;
virtual void setScissorRects(UInt count, ScissorRect const* rects) override;
virtual void setPipelineState(IPipelineState* state) override;
- virtual void draw(UInt vertexCount, UInt startVertex) override;
- virtual void drawIndexed(UInt indexCount, UInt startIndex, UInt baseVertex) override;
+ virtual void draw(uint32_t vertexCount, uint32_t startVertex) override;
+ virtual void drawIndexed(
+ uint32_t indexCount, uint32_t startIndex, uint32_t baseVertex) override;
virtual void dispatchCompute(int x, int y, int z) override;
virtual void submitGpuWork() override {}
virtual void waitForGpu() override {}
@@ -2597,11 +2599,11 @@ void GLDevice::setPrimitiveTopology(PrimitiveTopology topology)
}
void GLDevice::setVertexBuffers(
- UInt startSlot,
- UInt slotCount,
+ uint32_t startSlot,
+ uint32_t slotCount,
IBufferResource* const* buffers,
- const UInt* strides,
- const UInt* offsets)
+ const uint32_t* strides,
+ const uint32_t* offsets)
{
for (UInt ii = 0; ii < slotCount; ++ii)
{
@@ -2616,7 +2618,7 @@ void GLDevice::setVertexBuffers(
}
}
-void GLDevice::setIndexBuffer(IBufferResource* buffer, Format indexFormat, UInt offset)
+void GLDevice::setIndexBuffer(IBufferResource* buffer, Format indexFormat, uint32_t offset)
{
auto bufferImpl = static_cast<BufferResourceImpl*>(buffer);
m_boundIndexBuffer = bufferImpl->m_handle;
@@ -2675,14 +2677,14 @@ void GLDevice::setPipelineState(IPipelineState* state)
glUseProgram(programID);
}
-void GLDevice::draw(UInt vertexCount, UInt startVertex = 0)
+void GLDevice::draw(uint32_t vertexCount, uint32_t startVertex = 0)
{
flushStateForDraw();
glDrawArrays(m_boundPrimitiveTopology, (GLint)startVertex, (GLsizei)vertexCount);
}
-void GLDevice::drawIndexed(UInt indexCount, UInt startIndex, UInt baseVertex)
+void GLDevice::drawIndexed(uint32_t indexCount, uint32_t startIndex, uint32_t baseVertex)
{
flushStateForDraw();
diff --git a/tools/gfx/vulkan/render-vk.cpp b/tools/gfx/vulkan/render-vk.cpp
index 015f7e415..a363fb4a1 100644
--- a/tools/gfx/vulkan/render-vk.cpp
+++ b/tools/gfx/vulkan/render-vk.cpp
@@ -3982,11 +3982,11 @@ public:
}
virtual SLANG_NO_THROW void SLANG_MCALL setVertexBuffers(
- UInt startSlot,
- UInt slotCount,
+ uint32_t startSlot,
+ uint32_t slotCount,
IBufferResource* const* buffers,
- const UInt* strides,
- const UInt* offsets) override
+ const uint32_t* strides,
+ const uint32_t* offsets) override
{
{
const Index num = Index(startSlot + slotCount);
@@ -4007,9 +4007,7 @@ public:
}
virtual SLANG_NO_THROW void SLANG_MCALL setIndexBuffer(
- IBufferResource* buffer,
- Format indexFormat,
- UInt offset = 0) override
+ IBufferResource* buffer, Format indexFormat, uint32_t offset = 0) override
{
switch (indexFormat)
{
@@ -4039,7 +4037,7 @@ public:
}
virtual SLANG_NO_THROW void SLANG_MCALL
- draw(UInt vertexCount, UInt startVertex = 0) override
+ draw(uint32_t vertexCount, uint32_t startVertex = 0) override
{
prepareDraw();
auto& api = *m_api;
@@ -4053,10 +4051,10 @@ public:
api.vkCmdBindVertexBuffers(m_vkCommandBuffer, 0, 1, vertexBuffers, offsets);
}
- api.vkCmdDraw(m_vkCommandBuffer, static_cast<uint32_t>(vertexCount), 1, 0, 0);
+ api.vkCmdDraw(m_vkCommandBuffer, vertexCount, 1, 0, 0);
}
- virtual SLANG_NO_THROW void SLANG_MCALL
- drawIndexed(UInt indexCount, UInt startIndex = 0, UInt baseVertex = 0) override
+ virtual SLANG_NO_THROW void SLANG_MCALL drawIndexed(
+ uint32_t indexCount, uint32_t startIndex = 0, uint32_t baseVertex = 0) override
{
prepareDraw();
auto& api = *m_api;
@@ -4075,7 +4073,7 @@ public:
api.vkCmdBindVertexBuffers(m_vkCommandBuffer, 0, 1, vertexBuffers, offsets);
}
- api.vkCmdDraw(m_vkCommandBuffer, static_cast<uint32_t>(indexCount), 1, 0, 0);
+ api.vkCmdDraw(m_vkCommandBuffer, indexCount, 1, 0, 0);
}
virtual SLANG_NO_THROW void SLANG_MCALL
@@ -4147,10 +4145,10 @@ public:
}
virtual SLANG_NO_THROW void SLANG_MCALL drawInstanced(
- UInt vertexCount,
- UInt instanceCount,
- UInt startVertex,
- UInt startInstanceLocation) override
+ uint32_t vertexCount,
+ uint32_t instanceCount,
+ uint32_t startVertex,
+ uint32_t startInstanceLocation) override
{
prepareDraw();
auto& api = *m_api;
@@ -4164,8 +4162,12 @@ public:
api.vkCmdBindVertexBuffers(m_vkCommandBuffer, 0, 1, vertexBuffers, offsets);
}
- api.vkCmdDraw(m_vkCommandBuffer, static_cast<uint32_t>(vertexCount), static_cast<uint32_t>(instanceCount),
- static_cast<uint32_t>(startVertex), static_cast<uint32_t>(startInstanceLocation));
+ api.vkCmdDraw(
+ m_vkCommandBuffer,
+ vertexCount,
+ instanceCount,
+ startVertex,
+ startInstanceLocation);
}
virtual SLANG_NO_THROW void SLANG_MCALL drawIndexedInstanced(
@@ -4192,8 +4194,12 @@ public:
api.vkCmdBindVertexBuffers(m_vkCommandBuffer, 0, 1, vertexBuffers, offsets);
}
- api.vkCmdDraw(m_vkCommandBuffer, static_cast<uint32_t>(indexCount), static_cast<uint32_t>(instanceCount),
- static_cast<uint32_t>(baseVertexLocation), static_cast<uint32_t>(startInstanceLocation));
+ api.vkCmdDraw(
+ m_vkCommandBuffer,
+ indexCount,
+ instanceCount,
+ baseVertexLocation,
+ startInstanceLocation);
}
};
@@ -4924,6 +4930,8 @@ public:
case QueryType::AccelerationStructureSerializedSize:
queryType = VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR;
break;
+ case QueryType::AccelerationStructureCurrentSize:
+ continue;
default:
getDebugCallback()->handleMessage(DebugMessageType::Error, DebugMessageSource::Layer,
"Invalid query type for use in queryAccelerationStructureProperties.");
@@ -5364,6 +5372,7 @@ public:
Result init(const IQueryPool::Desc& desc, VKDevice* device)
{
m_device = device;
+ m_pool = VK_NULL_HANDLE;
VkQueryPoolCreateInfo createInfo = {};
createInfo.sType = VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO;
createInfo.queryCount = (uint32_t)desc.count;
@@ -5378,6 +5387,9 @@ public:
case QueryType::AccelerationStructureSerializedSize:
createInfo.queryType = VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR;
break;
+ case QueryType::AccelerationStructureCurrentSize:
+ // Vulkan does not support CurrentSize query, will not create actual pools here.
+ return SLANG_OK;
default:
return SLANG_E_INVALID_ARG;
}
@@ -5392,6 +5404,14 @@ public:
public:
virtual SLANG_NO_THROW Result SLANG_MCALL getResult(SlangInt index, SlangInt count, uint64_t* data) override
{
+ if (!m_pool)
+ {
+ // Vulkan does not support CurrentSize query, return 0 here.
+ for (SlangInt i = 0; i < count; i++)
+ data[i] = 0;
+ return SLANG_OK;
+ }
+
SLANG_VK_RETURN_ON_FAIL(m_device->m_api.vkGetQueryPoolResults(
m_device->m_api.m_device,
m_pool,