diff --git a/Include/Extensions/NRIWrapperD3D11.h b/Include/Extensions/NRIWrapperD3D11.h index 5bc75883..7bd16ebd 100644 --- a/Include/Extensions/NRIWrapperD3D11.h +++ b/Include/Extensions/NRIWrapperD3D11.h @@ -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) diff --git a/Include/Extensions/NRIWrapperD3D12.h b/Include/Extensions/NRIWrapperD3D12.h index e22be0e8..a40caa08 100644 --- a/Include/Extensions/NRIWrapperD3D12.h +++ b/Include/Extensions/NRIWrapperD3D12.h @@ -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) diff --git a/Source/D3D11/BufferD3D11.cpp b/Source/D3D11/BufferD3D11.cpp index 3e58bd7d..4fc71a94 100644 --- a/Source/D3D11/BufferD3D11.cpp +++ b/Source/D3D11/BufferD3D11.cpp @@ -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); diff --git a/Source/D3D11/CommandBufferD3D11.hpp b/Source/D3D11/CommandBufferD3D11.hpp index 60e28351..9f6e5d96 100644 --- a/Source/D3D11/CommandBufferD3D11.hpp +++ b/Source/D3D11/CommandBufferD3D11.hpp @@ -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); } diff --git a/Source/D3D11/CommandBufferEmuD3D11.cpp b/Source/D3D11/CommandBufferEmuD3D11.cpp index 2bfbd299..38ae576e 100644 --- a/Source/D3D11/CommandBufferEmuD3D11.cpp +++ b/Source/D3D11/CommandBufferEmuD3D11.cpp @@ -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); diff --git a/Source/D3D11/CommandBufferEmuD3D11.hpp b/Source/D3D11/CommandBufferEmuD3D11.hpp index 0a437cf0..ad78ebc1 100644 --- a/Source/D3D11/CommandBufferEmuD3D11.hpp +++ b/Source/D3D11/CommandBufferEmuD3D11.hpp @@ -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); } diff --git a/Source/D3D11/DeviceD3D11.cpp b/Source/D3D11/DeviceD3D11.cpp index 4590b716..e99ea9e5 100644 --- a/Source/D3D11/DeviceD3D11.cpp +++ b/Source/D3D11/DeviceD3D11.cpp @@ -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); diff --git a/Source/D3D11/SharedD3D11.h b/Source/D3D11/SharedD3D11.h index 20dda664..7f2184b6 100644 --- a/Source/D3D11/SharedD3D11.h +++ b/Source/D3D11/SharedD3D11.h @@ -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 { diff --git a/Source/D3D11/TextureD3D11.cpp b/Source/D3D11/TextureD3D11.cpp index 85fcd48b..6e9d7327 100644 --- a/Source/D3D11/TextureD3D11.cpp +++ b/Source/D3D11/TextureD3D11.cpp @@ -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; } diff --git a/Source/D3D12/BufferD3D12.cpp b/Source/D3D12/BufferD3D12.cpp index af5fd5d8..f9691e61 100644 --- a/Source/D3D12/BufferD3D12.cpp +++ b/Source/D3D12/BufferD3D12.cpp @@ -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; @@ -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 = diff --git a/Source/D3D12/CommandBufferD3D12.cpp b/Source/D3D12/CommandBufferD3D12.cpp index b750e78f..7d50b636 100644 --- a/Source/D3D12/CommandBufferD3D12.cpp +++ b/Source/D3D12/CommandBufferD3D12.cpp @@ -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) { diff --git a/Source/D3D12/CommandBufferD3D12.hpp b/Source/D3D12/CommandBufferD3D12.hpp index 11a0fc84..42bb1dd8 100644 --- a/Source/D3D12/CommandBufferD3D12.hpp +++ b/Source/D3D12/CommandBufferD3D12.hpp @@ -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); } diff --git a/Source/D3D12/DescriptorPoolD3D12.cpp b/Source/D3D12/DescriptorPoolD3D12.cpp index 95734538..acadc738 100644 --- a/Source/D3D12/DescriptorPoolD3D12.cpp +++ b/Source/D3D12/DescriptorPoolD3D12.cpp @@ -48,22 +48,20 @@ Result DescriptorPoolD3D12::Create(const DescriptorPoolD3D12Desc& descriptorPool static_assert(static_cast(DescriptorHeapType::SAMPLER) == 1, "DescriptorHeapType::SAMPLER != 1"); const std::array 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)); diff --git a/Source/D3D12/PipelineLayoutD3D12.cpp b/Source/D3D12/PipelineLayoutD3D12.cpp index a775dbb8..32fdb5e4 100644 --- a/Source/D3D12/PipelineLayoutD3D12.cpp +++ b/Source/D3D12/PipelineLayoutD3D12.cpp @@ -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; diff --git a/Source/D3D12/SharedD3D12.cpp b/Source/D3D12/SharedD3D12.cpp index 81cc7a58..206b4db3 100644 --- a/Source/D3D12/SharedD3D12.cpp +++ b/Source/D3D12/SharedD3D12.cpp @@ -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."); diff --git a/Source/D3D12/SharedD3D12.h b/Source/D3D12/SharedD3D12.h index f029fba7..da5ecf61 100644 --- a/Source/D3D12/SharedD3D12.h +++ b/Source/D3D12/SharedD3D12.h @@ -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); @@ -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 { diff --git a/Source/D3D12/TextureD3D12.cpp b/Source/D3D12/TextureD3D12.cpp index 2d4ce473..80a282ab 100644 --- a/Source/D3D12/TextureD3D12.cpp +++ b/Source/D3D12/TextureD3D12.cpp @@ -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; diff --git a/Source/Shared/D3DExt.hpp b/Source/Shared/D3DExt.hpp index 78f5d649..c24f6c9c 100644 --- a/Source/Shared/D3DExt.hpp +++ b/Source/Shared/D3DExt.hpp @@ -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); diff --git a/Source/VK/CommandBufferVK.cpp b/Source/VK/CommandBufferVK.cpp index fcf104a3..ed5f6786 100644 --- a/Source/VK/CommandBufferVK.cpp +++ b/Source/VK/CommandBufferVK.cpp @@ -380,8 +380,7 @@ inline void CommandBufferVK::DrawIndirect(const Buffer& buffer, uint64_t offset, if (countBuffer) { const VkBuffer countBufferHandle = GetVulkanHandle(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); } @@ -392,8 +391,7 @@ inline void CommandBufferVK::DrawIndexedIndirect(const Buffer& buffer, uint64_t if (countBuffer) { const VkBuffer countBufferHandle = GetVulkanHandle(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); } diff --git a/Source/VK/CommandBufferVK.hpp b/Source/VK/CommandBufferVK.hpp index a2406de1..ee42aa97 100644 --- a/Source/VK/CommandBufferVK.hpp +++ b/Source/VK/CommandBufferVK.hpp @@ -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); } diff --git a/Source/VK/ConversionVK.h b/Source/VK/ConversionVK.h index c0f5e35e..e611aaac 100644 --- a/Source/VK/ConversionVK.h +++ b/Source/VK/ConversionVK.h @@ -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; } } diff --git a/Source/VK/SwapChainVK.cpp b/Source/VK/SwapChainVK.cpp index 5955fcf6..6ebb8024 100644 --- a/Source/VK/SwapChainVK.cpp +++ b/Source/VK/SwapChainVK.cpp @@ -151,7 +151,8 @@ Result SwapChainVK::Create(const SwapChainDesc& swapChainDesc) { RETURN_ON_FAILURE(&m_Device, isHeightValid, Result::INVALID_ARGUMENT, "swapChainDesc.height is out of [%u, %u] range", sc.surfaceCapabilities.minImageExtent.height, sc.surfaceCapabilities.maxImageExtent.height); - bool isTextureNumValid = textureNum >= sc.surfaceCapabilities.minImageCount && (textureNum <= sc.surfaceCapabilities.maxImageCount || sc.surfaceCapabilities.maxImageCount == 0); + bool isTextureNumValid = + textureNum >= sc.surfaceCapabilities.minImageCount && (textureNum <= sc.surfaceCapabilities.maxImageCount || sc.surfaceCapabilities.maxImageCount == 0); RETURN_ON_FAILURE(&m_Device, isTextureNumValid, Result::INVALID_ARGUMENT, "swapChainDesc.textureNum is out of [%u, %u] range", sc.surfaceCapabilities.minImageCount, sc.surfaceCapabilities.maxImageCount); } diff --git a/Source/Validation/CommandBufferVal.hpp b/Source/Validation/CommandBufferVal.hpp index 756099a5..0ba2c73e 100644 --- a/Source/Validation/CommandBufferVal.hpp +++ b/Source/Validation/CommandBufferVal.hpp @@ -91,11 +91,13 @@ static void NRI_CALL CmdDrawIndexed(CommandBuffer& commandBuffer, const DrawInde ((CommandBufferVal&)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) { ((CommandBufferVal&)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) { ((CommandBufferVal&)commandBuffer).DrawIndexedIndirect(buffer, offset, drawNum, stride, countBuffer, countBufferOffset); } diff --git a/Source/Validation/DeviceVal.cpp b/Source/Validation/DeviceVal.cpp index 5658e215..71e48dda 100644 --- a/Source/Validation/DeviceVal.cpp +++ b/Source/Validation/DeviceVal.cpp @@ -947,7 +947,6 @@ Result DeviceVal::CreateCommandBufferD3D11(const CommandBufferD3D11Desc& command Result DeviceVal::CreateBufferD3D11(const BufferD3D11Desc& bufferDesc, Buffer*& buffer) { RETURN_ON_FAILURE(this, bufferDesc.d3d11Resource != nullptr, Result::INVALID_ARGUMENT, "CreateBufferD3D11: 'bufferDesc.d3d11Resource' is NULL"); - RETURN_ON_FAILURE(this, bufferDesc.bufferDesc != nullptr, Result::INVALID_ARGUMENT, "CreateBufferD3D11: 'bufferDesc.bufferDesc' is NULL"); Buffer* bufferImpl = nullptr; const Result result = m_WrapperD3D11API.CreateBufferD3D11(m_Device, bufferDesc, bufferImpl); @@ -1017,7 +1016,6 @@ Result DeviceVal::CreateDescriptorPoolD3D12(const DescriptorPoolD3D12Desc& descr Result DeviceVal::CreateBufferD3D12(const BufferD3D12Desc& bufferDesc, Buffer*& buffer) { RETURN_ON_FAILURE(this, bufferDesc.d3d12Resource != nullptr, Result::INVALID_ARGUMENT, "CreateBufferD3D12: 'bufferDesc.d3d12Resource' is NULL"); - RETURN_ON_FAILURE(this, bufferDesc.bufferDesc != nullptr, Result::INVALID_ARGUMENT, "CreateBufferD3D12: 'bufferDesc.bufferDesc' is NULL"); Buffer* bufferImpl = nullptr; const Result result = m_WrapperD3D12API.CreateBufferD3D12(m_Device, bufferDesc, bufferImpl);