Skip to content

Commit

Permalink
Fixes for MR #77:
Browse files Browse the repository at this point in the history
- "bufferDesc" and "textureDesc" renamed to "desc" since they are already parts of "Buffer" or "Texture" descs
- "desc" parameter made optional
- D3D12: "GetBufferDesc" fills in all implicitly allowed usage bits
- applied formatting
  • Loading branch information
dzhdanNV committed Jul 14, 2024
1 parent d432a73 commit bc1e896
Show file tree
Hide file tree
Showing 24 changed files with 115 additions and 82 deletions.
4 changes: 2 additions & 2 deletions Include/Extensions/NRIWrapperD3D11.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ NRI_STRUCT(CommandBufferD3D11Desc)
NRI_STRUCT(BufferD3D11Desc)
{
ID3D11Resource* d3d11Resource;
const NRI_NAME(BufferDesc)* bufferDesc;
const NRI_NAME(BufferDesc)* desc; // Can be NULL, but not all information can be retrieved from the resource
};

NRI_STRUCT(TextureD3D11Desc)
{
ID3D11Resource* d3d11Resource;
const NRI_NAME(TextureDesc)* textureDesc;
const NRI_NAME(TextureDesc)* desc; // Can be NULL, but not all information can be retrieved from the resource
};

NRI_STRUCT(WrapperD3D11Interface)
Expand Down
4 changes: 2 additions & 2 deletions Include/Extensions/NRIWrapperD3D12.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ NRI_STRUCT(DescriptorPoolD3D12Desc)
NRI_STRUCT(BufferD3D12Desc)
{
ID3D12Resource* d3d12Resource;
const NRI_NAME(BufferDesc)* bufferDesc;
const NRI_NAME(BufferDesc)* desc; // Can be NULL, but not all information can be retrieved from the resource
uint32_t structureStride;
};

NRI_STRUCT(TextureD3D12Desc)
{
ID3D12Resource* d3d12Resource;
const NRI_NAME(TextureDesc)* textureDesc;
const NRI_NAME(TextureDesc)* desc; // Can be NULL, but not all information can be retrieved from the resource
};

NRI_STRUCT(MemoryD3D12Desc)
Expand Down
6 changes: 5 additions & 1 deletion Source/D3D11/BufferD3D11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,13 @@ Result BufferD3D11::Create(const MemoryD3D11& memory) {
}

Result BufferD3D11::Create(const BufferD3D11Desc& bufferDesc) {
if (bufferDesc.desc)
m_Desc = *bufferDesc.desc;
else if (!GetBufferDesc(bufferDesc, m_Desc))
return Result::INVALID_ARGUMENT;

ID3D11Buffer* buffer = (ID3D11Buffer*)bufferDesc.d3d11Resource;
m_Buffer = buffer;
m_Desc = *bufferDesc.bufferDesc;

D3D11_BUFFER_DESC desc = {};
buffer->GetDesc(&desc);
Expand Down
6 changes: 4 additions & 2 deletions Source/D3D11/CommandBufferD3D11.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,13 @@ static void NRI_CALL CmdDrawIndexed(CommandBuffer& commandBuffer, const DrawInde
((CommandBufferD3D11&)commandBuffer).DrawIndexed(drawIndexedDesc);
}

static void NRI_CALL CmdDrawIndirect(CommandBuffer& commandBuffer, const Buffer& buffer, uint64_t offset, uint32_t drawNum, uint32_t stride, const Buffer* countBuffer, uint64_t countBufferOffset) {
static void NRI_CALL CmdDrawIndirect(
CommandBuffer& commandBuffer, const Buffer& buffer, uint64_t offset, uint32_t drawNum, uint32_t stride, const Buffer* countBuffer, uint64_t countBufferOffset) {
((CommandBufferD3D11&)commandBuffer).DrawIndirect(buffer, offset, drawNum, stride, countBuffer, countBufferOffset);
}

static void NRI_CALL CmdDrawIndexedIndirect(CommandBuffer& commandBuffer, const Buffer& buffer, uint64_t offset, uint32_t drawNum, uint32_t stride, const Buffer* countBuffer, uint64_t countBufferOffset) {
static void NRI_CALL CmdDrawIndexedIndirect(
CommandBuffer& commandBuffer, const Buffer& buffer, uint64_t offset, uint32_t drawNum, uint32_t stride, const Buffer* countBuffer, uint64_t countBufferOffset) {
((CommandBufferD3D11&)commandBuffer).DrawIndexedIndirect(buffer, offset, drawNum, stride, countBuffer, countBufferOffset);
}

Expand Down
3 changes: 2 additions & 1 deletion Source/D3D11/CommandBufferEmuD3D11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,8 @@ inline void CommandBufferEmuD3D11::DrawIndirect(const Buffer& buffer, uint64_t o
Push(m_PushBuffer, countBufferOffset);
}

inline void CommandBufferEmuD3D11::DrawIndexedIndirect(const Buffer& buffer, uint64_t offset, uint32_t drawNum, uint32_t stride, const Buffer* countBuffer, uint64_t countBufferOffset) {
inline void CommandBufferEmuD3D11::DrawIndexedIndirect(
const Buffer& buffer, uint64_t offset, uint32_t drawNum, uint32_t stride, const Buffer* countBuffer, uint64_t countBufferOffset) {
Push(m_PushBuffer, DRAW_INDEXED_INDIRECT);
Push(m_PushBuffer, &buffer);
Push(m_PushBuffer, offset);
Expand Down
6 changes: 4 additions & 2 deletions Source/D3D11/CommandBufferEmuD3D11.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,13 @@ static void NRI_CALL CmdDrawIndexed(CommandBuffer& commandBuffer, const DrawInde
((CommandBufferEmuD3D11&)commandBuffer).DrawIndexed(drawIndexedDesc);
}

static void NRI_CALL CmdDrawIndirect(CommandBuffer& commandBuffer, const Buffer& buffer, uint64_t offset, uint32_t drawNum, uint32_t stride, const Buffer* countBuffer, uint64_t countBufferOffset) {
static void NRI_CALL CmdDrawIndirect(
CommandBuffer& commandBuffer, const Buffer& buffer, uint64_t offset, uint32_t drawNum, uint32_t stride, const Buffer* countBuffer, uint64_t countBufferOffset) {
((CommandBufferEmuD3D11&)commandBuffer).DrawIndirect(buffer, offset, drawNum, stride, countBuffer, countBufferOffset);
}

static void NRI_CALL CmdDrawIndexedIndirect(CommandBuffer& commandBuffer, const Buffer& buffer, uint64_t offset, uint32_t drawNum, uint32_t stride, const Buffer* countBuffer, uint64_t countBufferOffset) {
static void NRI_CALL CmdDrawIndexedIndirect(
CommandBuffer& commandBuffer, const Buffer& buffer, uint64_t offset, uint32_t drawNum, uint32_t stride, const Buffer* countBuffer, uint64_t countBufferOffset) {
((CommandBufferEmuD3D11&)commandBuffer).DrawIndexedIndirect(buffer, offset, drawNum, stride, countBuffer, countBufferOffset);
}

Expand Down
3 changes: 1 addition & 2 deletions Source/D3D11/DeviceD3D11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,7 @@ Result DeviceD3D11::Create(const DeviceCreationDesc& deviceCreationDesc, ID3D11D
m_Desc.isDepthBoundsTestSupported = isDepthBoundsTestSupported;
m_Desc.isDrawIndirectCountSupported = isDrawIndirectCountSupported;
m_Desc.isShaderAtomicsI64Supported = isShaderAtomicsI64Supported;
}
else
} else
m_IsWrapped = true;

m_Version = QueryLatestDevice(deviceTemp, m_Device);
Expand Down
6 changes: 3 additions & 3 deletions Source/D3D11/SharedD3D11.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,9 @@ struct SamplePositionsState {
} // namespace nri

#if NRI_USE_EXT_LIBS
#include "amdags/ags_lib/inc/amd_ags.h"
#include "nvapi/nvapi.h"
#include "nvapi/nvShaderExtnEnums.h"
# include "amdags/ags_lib/inc/amd_ags.h"
# include "nvapi/nvShaderExtnEnums.h"
# include "nvapi/nvapi.h"
#endif

namespace d3d11 {
Expand Down
12 changes: 5 additions & 7 deletions Source/D3D11/TextureD3D11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,12 @@ Result TextureD3D11::Create(const MemoryD3D11* memory) {
}

Result TextureD3D11::Create(const TextureD3D11Desc& textureDesc) {
if (!textureDesc.textureDesc) {
if (!GetTextureDesc(textureDesc, m_Desc))
return Result::INVALID_ARGUMENT;
} else {
m_Desc = *textureDesc.textureDesc;
}
if (textureDesc.desc)
m_Desc = *textureDesc.desc;
else if (!GetTextureDesc(textureDesc, m_Desc))
return Result::INVALID_ARGUMENT;

m_Texture = textureDesc.d3d11Resource;
m_Desc = *textureDesc.textureDesc;

return Result::SUCCESS;
}
Expand Down
9 changes: 6 additions & 3 deletions Source/D3D12/BufferD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ Result BufferD3D12::Create(const BufferDesc& bufferDesc) {
}

Result BufferD3D12::Create(const BufferD3D12Desc& bufferDesc) {
m_Desc = *bufferDesc.bufferDesc;
if (bufferDesc.desc)
m_Desc = *bufferDesc.desc;
else if (!GetBufferDesc(bufferDesc, m_Desc))
return Result::INVALID_ARGUMENT;

m_Buffer = (ID3D12ResourceBest*)bufferDesc.d3d12Resource;

return Result::SUCCESS;
Expand All @@ -50,8 +54,7 @@ Result BufferD3D12::BindMemory(const MemoryD3D12* memory, uint64_t offset, bool

if (memory->RequiresDedicatedAllocation()) {
HRESULT hr = m_Device->CreateCommittedResource3(
&heapDesc.Properties, heapDesc.Flags, &desc1, D3D12_BARRIER_LAYOUT_UNDEFINED, nullptr, nullptr,
castableFormatNum, castableFormats, IID_PPV_ARGS(&m_Buffer));
&heapDesc.Properties, heapDesc.Flags, &desc1, D3D12_BARRIER_LAYOUT_UNDEFINED, nullptr, nullptr, castableFormatNum, castableFormats, IID_PPV_ARGS(&m_Buffer));
RETURN_ON_BAD_HRESULT(&m_Device, hr, "ID3D12Device10::CreateCommittedResource3()");
} else {
HRESULT hr =
Expand Down
6 changes: 4 additions & 2 deletions Source/D3D12/CommandBufferD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,12 +484,14 @@ inline void CommandBufferD3D12::DrawIndirect(const Buffer& buffer, uint64_t offs
m_GraphicsCommandList->ExecuteIndirect(m_Device.GetDrawCommandSignature(stride, *m_PipelineLayout), drawNum, (BufferD3D12&)buffer, offset, pCountBuffer, countBufferOffset);
}

inline void CommandBufferD3D12::DrawIndexedIndirect(const Buffer& buffer, uint64_t offset, uint32_t drawNum, uint32_t stride, const Buffer* countBuffer, uint64_t countBufferOffset) {
inline void CommandBufferD3D12::DrawIndexedIndirect(
const Buffer& buffer, uint64_t offset, uint32_t drawNum, uint32_t stride, const Buffer* countBuffer, uint64_t countBufferOffset) {
ID3D12Resource* pCountBuffer = nullptr;
if (countBuffer)
pCountBuffer = *(BufferD3D12*)countBuffer;

m_GraphicsCommandList->ExecuteIndirect(m_Device.GetDrawIndexedCommandSignature(stride, *m_PipelineLayout), drawNum, (BufferD3D12&)buffer, offset, pCountBuffer, countBufferOffset);
m_GraphicsCommandList->ExecuteIndirect(
m_Device.GetDrawIndexedCommandSignature(stride, *m_PipelineLayout), drawNum, (BufferD3D12&)buffer, offset, pCountBuffer, countBufferOffset);
}

inline void CommandBufferD3D12::CopyBuffer(Buffer& dstBuffer, uint64_t dstOffset, const Buffer& srcBuffer, uint64_t srcOffset, uint64_t size) {
Expand Down
6 changes: 4 additions & 2 deletions Source/D3D12/CommandBufferD3D12.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,13 @@ static void NRI_CALL CmdDrawIndexed(CommandBuffer& commandBuffer, const DrawInde
((CommandBufferD3D12&)commandBuffer).DrawIndexed(drawIndexedDesc);
}

static void NRI_CALL CmdDrawIndirect(CommandBuffer& commandBuffer, const Buffer& buffer, uint64_t offset, uint32_t drawNum, uint32_t stride, const Buffer* countBuffer, uint64_t countBufferOffset) {
static void NRI_CALL CmdDrawIndirect(
CommandBuffer& commandBuffer, const Buffer& buffer, uint64_t offset, uint32_t drawNum, uint32_t stride, const Buffer* countBuffer, uint64_t countBufferOffset) {
((CommandBufferD3D12&)commandBuffer).DrawIndirect(buffer, offset, drawNum, stride, countBuffer, countBufferOffset);
}

static void NRI_CALL CmdDrawIndexedIndirect(CommandBuffer& commandBuffer, const Buffer& buffer, uint64_t offset, uint32_t drawNum, uint32_t stride, const Buffer* countBuffer, uint64_t countBufferOffset) {
static void NRI_CALL CmdDrawIndexedIndirect(
CommandBuffer& commandBuffer, const Buffer& buffer, uint64_t offset, uint32_t drawNum, uint32_t stride, const Buffer* countBuffer, uint64_t countBufferOffset) {
((CommandBufferD3D12&)commandBuffer).DrawIndexedIndirect(buffer, offset, drawNum, stride, countBuffer, countBufferOffset);
}

Expand Down
26 changes: 12 additions & 14 deletions Source/D3D12/DescriptorPoolD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,20 @@ Result DescriptorPoolD3D12::Create(const DescriptorPoolD3D12Desc& descriptorPool
static_assert(static_cast<uint32_t>(DescriptorHeapType::SAMPLER) == 1, "DescriptorHeapType::SAMPLER != 1");

const std::array<ID3D12DescriptorHeap*, DescriptorHeapType::MAX_NUM> descriptorHeaps = {
descriptorPoolDesc.d3d12ResourceDescriptorHeap,
descriptorPoolDesc.d3d12SamplerDescriptorHeap
};
descriptorPoolDesc.d3d12ResourceDescriptorHeap, descriptorPoolDesc.d3d12SamplerDescriptorHeap};

for (uint32_t i = 0; i < DescriptorHeapType::MAX_NUM; i++) {
if (descriptorHeaps[i]) {
D3D12_DESCRIPTOR_HEAP_DESC desc = descriptorHeaps[i]->GetDesc();
m_DescriptorHeapDescs[i].descriptorHeap = descriptorHeaps[i];
m_DescriptorHeapDescs[i].descriptorPointerCPU = descriptorHeaps[i]->GetCPUDescriptorHandleForHeapStart().ptr;
m_DescriptorHeapDescs[i].descriptorPointerGPU = descriptorHeaps[i]->GetGPUDescriptorHandleForHeapStart().ptr;
m_DescriptorHeapDescs[i].descriptorSize = m_Device->GetDescriptorHandleIncrementSize(desc.Type);

m_DescriptorHeaps[m_DescriptorHeapNum] = descriptorHeaps[i];
m_DescriptorHeapNum++;
}
}
if (descriptorHeaps[i]) {
D3D12_DESCRIPTOR_HEAP_DESC desc = descriptorHeaps[i]->GetDesc();
m_DescriptorHeapDescs[i].descriptorHeap = descriptorHeaps[i];
m_DescriptorHeapDescs[i].descriptorPointerCPU = descriptorHeaps[i]->GetCPUDescriptorHandleForHeapStart().ptr;
m_DescriptorHeapDescs[i].descriptorPointerGPU = descriptorHeaps[i]->GetGPUDescriptorHandleForHeapStart().ptr;
m_DescriptorHeapDescs[i].descriptorSize = m_Device->GetDescriptorHandleIncrementSize(desc.Type);

m_DescriptorHeaps[m_DescriptorHeapNum] = descriptorHeaps[i];
m_DescriptorHeapNum++;
}
}

m_DescriptorSets.resize(descriptorPoolDesc.descriptorSetMaxNum, DescriptorSetD3D12(*this));

Expand Down
8 changes: 3 additions & 5 deletions Source/D3D12/PipelineLayoutD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,9 @@ Result PipelineLayoutD3D12::Create(const PipelineLayoutDesc& pipelineLayoutDesc)

D3D12_ROOT_PARAMETER1 rootParameterLocal = {};

bool enableDrawParametersEmulation =
m_Device.GetDesc().isDrawParametersEmulationEnabled &&
pipelineLayoutDesc.enableD3D12DrawParametersEmulation &&
(pipelineLayoutDesc.shaderStages & nri::StageBits::VERTEX_SHADER);

bool enableDrawParametersEmulation = m_Device.GetDesc().isDrawParametersEmulationEnabled && pipelineLayoutDesc.enableD3D12DrawParametersEmulation &&
(pipelineLayoutDesc.shaderStages & nri::StageBits::VERTEX_SHADER);

if (enableDrawParametersEmulation) {
rootParameterLocal.ParameterType = D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS;
rootParameterLocal.ShaderVisibility = D3D12_SHADER_VISIBILITY_VERTEX;
Expand Down
26 changes: 26 additions & 0 deletions Source/D3D12/SharedD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,32 @@ bool nri::GetTextureDesc(const TextureD3D12Desc& textureD3D12Desc, TextureDesc&
return true;
}

bool nri::GetBufferDesc(const BufferD3D12Desc& bufferD3D12Desc, BufferDesc& bufferDesc) {
bufferDesc = {};

ID3D12Resource* resource = bufferD3D12Desc.d3d12Resource;
if (!resource)
return false;

D3D12_RESOURCE_DESC desc = resource->GetDesc();
if (desc.Dimension != D3D12_RESOURCE_DIMENSION_BUFFER)
return false;

bufferDesc.size = desc.Width;
bufferDesc.structureStride = bufferD3D12Desc.structureStride;

// There are almost no restrictions on usages in D3D12
bufferDesc.usageMask = BufferUsageBits::VERTEX_BUFFER | BufferUsageBits::INDEX_BUFFER | BufferUsageBits::CONSTANT_BUFFER | BufferUsageBits::ARGUMENT_BUFFER |
BufferUsageBits::RAY_TRACING_BUFFER | BufferUsageBits::ACCELERATION_STRUCTURE_BUILD_READ;

if (!(desc.Flags & D3D12_RESOURCE_FLAG_DENY_SHADER_RESOURCE))
bufferDesc.usageMask |= BufferUsageBits::SHADER_RESOURCE;
if (desc.Flags & D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS)
bufferDesc.usageMask |= BufferUsageBits::SHADER_RESOURCE_STORAGE;

return true;
}

D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE nri::GetAccelerationStructureType(AccelerationStructureType accelerationStructureType) {
static_assert(D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL == (uint32_t)AccelerationStructureType::TOP_LEVEL, "Unsupported AccelerationStructureType.");
static_assert(D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL == (uint32_t)AccelerationStructureType::BOTTOM_LEVEL, "Unsupported AccelerationStructureType.");
Expand Down
7 changes: 4 additions & 3 deletions Source/D3D12/SharedD3D12.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ bool RequiresDedicatedAllocation(MemoryType memoryType);
void ConvertGeometryDescs(D3D12_RAYTRACING_GEOMETRY_DESC* geometryDescs, const GeometryObject* geometryObjects, uint32_t geometryObjectNum);
void ConvertRects(D3D12_RECT* rectsD3D12, const Rect* rects, uint32_t rectNum);
bool GetTextureDesc(const TextureD3D12Desc& textureD3D12Desc, TextureDesc& textureDesc);
bool GetBufferDesc(const BufferD3D12Desc& bufferD3D12Desc, BufferDesc& bufferDesc);
uint64_t GetMemorySizeD3D12(const MemoryD3D12Desc& memoryD3D12Desc);

D3D12_FILTER GetFilterIsotropic(Filter mip, Filter magnification, Filter minification, FilterExt filterExt, bool useComparison);
Expand All @@ -71,9 +72,9 @@ D3D12_RESOURCE_DIMENSION GetResourceDimension(TextureType textureType);
} // namespace nri

#if NRI_USE_EXT_LIBS
#include "amdags/ags_lib/inc/amd_ags.h"
#include "nvapi/nvapi.h"
#include "nvapi/nvShaderExtnEnums.h"
# include "amdags/ags_lib/inc/amd_ags.h"
# include "nvapi/nvShaderExtnEnums.h"
# include "nvapi/nvapi.h"
#endif

namespace d3d12 {
Expand Down
10 changes: 4 additions & 6 deletions Source/D3D12/TextureD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,10 @@ Result TextureD3D12::Create(const TextureDesc& textureDesc) {
}

Result TextureD3D12::Create(const TextureD3D12Desc& textureDesc) {
if (!textureDesc.textureDesc) {
if (!GetTextureDesc(textureDesc, m_Desc))
return Result::INVALID_ARGUMENT;
} else {
m_Desc = *textureDesc.textureDesc;
}
if (textureDesc.desc)
m_Desc = *textureDesc.desc;
else if (!GetTextureDesc(textureDesc, m_Desc))
return Result::INVALID_ARGUMENT;

m_Texture = (ID3D12ResourceBest*)textureDesc.d3d12Resource;

Expand Down
3 changes: 1 addition & 2 deletions Source/Shared/D3DExt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,7 @@ void Ext::DrawIndexedIndirect(
// D3D11
# if defined(__d3d11_h__)

void Ext::DrawIndirect(
ID3D11DeviceContext* deviceContext, ID3D11Buffer* buffer, uint64_t offset, uint32_t drawNum, uint32_t stride, ID3D11Buffer* countBuffer, uint32_t) const {
void Ext::DrawIndirect(ID3D11DeviceContext* deviceContext, ID3D11Buffer* buffer, uint64_t offset, uint32_t drawNum, uint32_t stride, ID3D11Buffer* countBuffer, uint32_t) const {
if (!countBuffer) {
for (uint32_t i = 0; i < drawNum; i++) {
deviceContext->DrawInstancedIndirect(buffer, (uint32_t)offset);
Expand Down
6 changes: 2 additions & 4 deletions Source/VK/CommandBufferVK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,7 @@ inline void CommandBufferVK::DrawIndirect(const Buffer& buffer, uint64_t offset,
if (countBuffer) {
const VkBuffer countBufferHandle = GetVulkanHandle<VkBuffer, BufferVK>(countBuffer);
vk.CmdDrawIndirectCount(m_Handle, bufferHandle, offset, countBufferHandle, countBufferOffset, drawNum, (uint32_t)stride);
}
else
} else
vk.CmdDrawIndirect(m_Handle, bufferHandle, offset, drawNum, (uint32_t)stride);
}

Expand All @@ -392,8 +391,7 @@ inline void CommandBufferVK::DrawIndexedIndirect(const Buffer& buffer, uint64_t
if (countBuffer) {
const VkBuffer countBufferHandle = GetVulkanHandle<VkBuffer, BufferVK>(countBuffer);
vk.CmdDrawIndexedIndirectCount(m_Handle, bufferHandle, offset, countBufferHandle, countBufferOffset, drawNum, (uint32_t)stride);
}
else
} else
vk.CmdDrawIndexedIndirect(m_Handle, bufferHandle, offset, drawNum, (uint32_t)stride);
}

Expand Down
6 changes: 4 additions & 2 deletions Source/VK/CommandBufferVK.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,13 @@ static void NRI_CALL CmdDrawIndexed(CommandBuffer& commandBuffer, const DrawInde
((CommandBufferVK&)commandBuffer).DrawIndexed(drawIndexedDesc);
}

static void NRI_CALL CmdDrawIndirect(CommandBuffer& commandBuffer, const Buffer& buffer, uint64_t offset, uint32_t drawNum, uint32_t stride, const Buffer* countBuffer, uint64_t countBufferOffset) {
static void NRI_CALL CmdDrawIndirect(
CommandBuffer& commandBuffer, const Buffer& buffer, uint64_t offset, uint32_t drawNum, uint32_t stride, const Buffer* countBuffer, uint64_t countBufferOffset) {
((CommandBufferVK&)commandBuffer).DrawIndirect(buffer, offset, drawNum, stride, countBuffer, countBufferOffset);
}

static void NRI_CALL CmdDrawIndexedIndirect(CommandBuffer& commandBuffer, const Buffer& buffer, uint64_t offset, uint32_t drawNum, uint32_t stride, const Buffer* countBuffer, uint64_t countBufferOffset) {
static void NRI_CALL CmdDrawIndexedIndirect(
CommandBuffer& commandBuffer, const Buffer& buffer, uint64_t offset, uint32_t drawNum, uint32_t stride, const Buffer* countBuffer, uint64_t countBufferOffset) {
((CommandBufferVK&)commandBuffer).DrawIndexedIndirect(buffer, offset, drawNum, stride, countBuffer, countBufferOffset);
}

Expand Down
23 changes: 11 additions & 12 deletions Source/VK/ConversionVK.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,18 +165,17 @@ inline VkFormat GetVkFormat(Format format, bool demoteSrgb = false) {
}

inline bool HasStencil(Format format) {
switch (format)
{
case nri::Format::D24_UNORM_S8_UINT:
return true;
case nri::Format::D32_SFLOAT_S8_UINT_X24:
return true;
case nri::Format::X24_G8_UINT:
return true;
case nri::Format::X32_G8_UINT_X24:
return true;
default:
return false;
switch (format) {
case nri::Format::D24_UNORM_S8_UINT:
return true;
case nri::Format::D32_SFLOAT_S8_UINT_X24:
return true;
case nri::Format::X24_G8_UINT:
return true;
case nri::Format::X32_G8_UINT_X24:
return true;
default:
return false;
}
}

Expand Down
Loading

0 comments on commit bc1e896

Please sign in to comment.