From ec49c32fd176e10528949f87a4b2cea74e7bb7d4 Mon Sep 17 00:00:00 2001 From: MJP Date: Tue, 31 Jan 2017 23:28:56 -0800 Subject: [PATCH] Fixed a validation error, and removed unnecessary post-upload transitions out of the COMMON state --- SampleFramework12/v1.00/Graphics/GraphicsTypes.cpp | 3 --- SampleFramework12/v1.00/Graphics/SpriteRenderer.cpp | 10 ++++++++-- SampleFramework12/v1.00/Graphics/Textures.cpp | 11 ----------- SampleFramework12/v1.00/Shaders/Sprite.hlsl | 2 +- 4 files changed, 9 insertions(+), 17 deletions(-) diff --git a/SampleFramework12/v1.00/Graphics/GraphicsTypes.cpp b/SampleFramework12/v1.00/Graphics/GraphicsTypes.cpp index 9880150..6e3023e 100644 --- a/SampleFramework12/v1.00/Graphics/GraphicsTypes.cpp +++ b/SampleFramework12/v1.00/Graphics/GraphicsTypes.cpp @@ -250,9 +250,6 @@ void Buffer::Initialize(uint64 size, uint64 alignment, bool32 dynamic, BufferLif uploadContext.CmdList->CopyBufferRegion(Resource, 0, uploadContext.Resource, uploadContext.ResourceOffset, size); DX12::ResourceUploadEnd(uploadContext); - - if(initialState != D3D12_RESOURCE_STATE_COPY_DEST) - DX12::TransitionResource(DX12::CmdList, Resource, D3D12_RESOURCE_STATE_COPY_DEST, initialState); } } } diff --git a/SampleFramework12/v1.00/Graphics/SpriteRenderer.cpp b/SampleFramework12/v1.00/Graphics/SpriteRenderer.cpp index cc3011c..0aec7d4 100644 --- a/SampleFramework12/v1.00/Graphics/SpriteRenderer.cpp +++ b/SampleFramework12/v1.00/Graphics/SpriteRenderer.cpp @@ -69,15 +69,21 @@ void SpriteRenderer::Initialize() ranges[0].RegisterSpace = 0; ranges[0].OffsetInDescriptorsFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND; + ranges[1].RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_SRV; + ranges[1].NumDescriptors = 1; + ranges[1].BaseShaderRegister = 1; + ranges[1].RegisterSpace = 0; + ranges[1].OffsetInDescriptorsFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND; + D3D12_ROOT_PARAMETER1 rootParameters[NumRootParams] = { }; rootParameters[SRVParam_VS].ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE; rootParameters[SRVParam_VS].ShaderVisibility = D3D12_SHADER_VISIBILITY_VERTEX; - rootParameters[SRVParam_VS].DescriptorTable.pDescriptorRanges = ranges; + rootParameters[SRVParam_VS].DescriptorTable.pDescriptorRanges = &ranges[0]; rootParameters[SRVParam_VS].DescriptorTable.NumDescriptorRanges = 1; rootParameters[SRVParam_PS].ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE; rootParameters[SRVParam_PS].ShaderVisibility = D3D12_SHADER_VISIBILITY_PIXEL; - rootParameters[SRVParam_PS].DescriptorTable.pDescriptorRanges = ranges; + rootParameters[SRVParam_PS].DescriptorTable.pDescriptorRanges = &ranges[1]; rootParameters[SRVParam_PS].DescriptorTable.NumDescriptorRanges = 1; rootParameters[CBVParam].ParameterType = D3D12_ROOT_PARAMETER_TYPE_CBV; diff --git a/SampleFramework12/v1.00/Graphics/Textures.cpp b/SampleFramework12/v1.00/Graphics/Textures.cpp index 271c75b..be986d9 100644 --- a/SampleFramework12/v1.00/Graphics/Textures.cpp +++ b/SampleFramework12/v1.00/Graphics/Textures.cpp @@ -160,9 +160,6 @@ void LoadTexture(Texture& texture, const wchar* filePath, bool forceSRGB) DX12::ResourceUploadEnd(uploadContext); - DX12::TransitionResource(DX12::CmdList, texture.Resource, D3D12_RESOURCE_STATE_COPY_DEST, - D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE | D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - texture.Width = uint32(metaData.width); texture.Height = uint32(metaData.height); texture.Depth = uint32(metaData.depth); @@ -259,11 +256,7 @@ void Create2DTexture(Texture& texture, uint64 width, uint64 height, uint64 numMi texture.Cubemap = cubeMap; if(initData != nullptr) - { UploadTextureData(texture, initData); - - DX12::TransitionResource(DX12::CmdList, texture.Resource, D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); - } } void Create3DTexture(Texture& texture, uint64 width, uint64 height, uint64 depth, uint64 numMips, DXGI_FORMAT format, const void* initData) @@ -317,11 +310,7 @@ void Create3DTexture(Texture& texture, uint64 width, uint64 height, uint64 depth texture.Cubemap = false; if(initData != nullptr) - { UploadTextureData(texture, initData); - - DX12::TransitionResource(DX12::CmdList, texture.Resource, D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); - } } void UploadTextureData(const Texture& texture, const void* initData) diff --git a/SampleFramework12/v1.00/Shaders/Sprite.hlsl b/SampleFramework12/v1.00/Shaders/Sprite.hlsl index a4763e3..3455517 100644 --- a/SampleFramework12/v1.00/Shaders/Sprite.hlsl +++ b/SampleFramework12/v1.00/Shaders/Sprite.hlsl @@ -30,7 +30,7 @@ struct SpriteDrawData // Resources //================================================================================================= StructuredBuffer SpriteBuffer : register(t0); -Texture2D SpriteTexture : register(t0); +Texture2D SpriteTexture : register(t1); SamplerState PointSampler : register(s0); SamplerState LinearSampler : register(s1);