Skip to content

Commit

Permalink
Fixed a validation error, and removed unnecessary post-upload transit…
Browse files Browse the repository at this point in the history
…ions out of the COMMON state
  • Loading branch information
TheRealMJP committed Feb 1, 2017
1 parent a8ffae6 commit ec49c32
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 17 deletions.
3 changes: 0 additions & 3 deletions SampleFramework12/v1.00/Graphics/GraphicsTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down
10 changes: 8 additions & 2 deletions SampleFramework12/v1.00/Graphics/SpriteRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 0 additions & 11 deletions SampleFramework12/v1.00/Graphics/Textures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion SampleFramework12/v1.00/Shaders/Sprite.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ struct SpriteDrawData
// Resources
//=================================================================================================
StructuredBuffer<SpriteDrawData> SpriteBuffer : register(t0);
Texture2D SpriteTexture : register(t0);
Texture2D SpriteTexture : register(t1);
SamplerState PointSampler : register(s0);
SamplerState LinearSampler : register(s1);

Expand Down

0 comments on commit ec49c32

Please sign in to comment.