diff options
| author | lucy96chen <47800040+lucy96chen@users.noreply.github.com> | 2022-03-08 12:47:32 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-03-08 15:47:32 -0500 |
| commit | 771f29435d664f7344bc5596056146af5d64d352 (patch) | |
| tree | 035fba1641088d75381e9a7140dab2d6f21223f9 /tools/gfx/d3d12/render-d3d12.cpp | |
| parent | 2a80bcfa96089967b299eea0454d9debe52fa0f6 (diff) | |
Expose API-specific row alignment values (#2151)
* Added function to IDevice that retrieves the row alignment for the particular API; Added rowDstStride argument to copyTextureToBuffer and changed D3D12 footprint row pitch to check that the user-supplied stride is correctly aligned before assigning to the footprint's row pitch
* Changed alignment from Uint to size_t
Co-authored-by: jsmall-nvidia <jsmall@nvidia.com>
Diffstat (limited to 'tools/gfx/d3d12/render-d3d12.cpp')
| -rw-r--r-- | tools/gfx/d3d12/render-d3d12.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/tools/gfx/d3d12/render-d3d12.cpp b/tools/gfx/d3d12/render-d3d12.cpp index c45ba2751..a6a0c7790 100644 --- a/tools/gfx/d3d12/render-d3d12.cpp +++ b/tools/gfx/d3d12/render-d3d12.cpp @@ -96,6 +96,7 @@ public: virtual SLANG_NO_THROW Result SLANG_MCALL getTextureAllocationInfo( const ITextureResource::Desc& desc, size_t* outSize, size_t* outAlignment) override; + virtual SLANG_NO_THROW Result SLANG_MCALL getTextureRowAlignment(size_t* outAlignment) override; virtual SLANG_NO_THROW Result SLANG_MCALL createTextureResource( const ITextureResource::Desc& desc, const ITextureResource::SubresourceData* initData, @@ -4388,6 +4389,7 @@ public: IBufferResource* dst, size_t dstOffset, size_t dstSize, + size_t dstRowStride, ITextureResource* src, ResourceState srcState, SubresourceRange srcSubresource, @@ -4462,9 +4464,9 @@ public: footprint.Footprint.Depth = Math::Max(1, (textureSize.depth >> mipLevel)) - srcOffset.z; } - footprint.Footprint.RowPitch = (UINT)D3DUtil::calcAligned( - footprint.Footprint.Width * (UInt)formatInfo.blockSizeInBytes, - (uint32_t)D3D12_TEXTURE_DATA_PITCH_ALIGNMENT); + + assert(dstRowStride % D3D12_TEXTURE_DATA_PITCH_ALIGNMENT == 0); + footprint.Footprint.RowPitch = dstRowStride; auto bufferSize = footprint.Footprint.RowPitch * footprint.Footprint.Height * footprint.Footprint.Depth; @@ -6759,6 +6761,12 @@ Result D3D12Device::getTextureAllocationInfo( return SLANG_OK; } +Result D3D12Device::getTextureRowAlignment(size_t* outAlignment) +{ + *outAlignment = D3D12_TEXTURE_DATA_PITCH_ALIGNMENT; + return SLANG_OK; +} + Result D3D12Device::createTextureResource(const ITextureResource::Desc& descIn, const ITextureResource::SubresourceData* initData, ITextureResource** outResource) { // Description of uploading on Dx12 |
