summaryrefslogtreecommitdiffstats
path: root/tools/render-test/render-d3d12.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2018-06-01 10:41:13 -0400
committerTim Foley <tfoleyNV@users.noreply.github.com>2018-06-01 07:41:13 -0700
commit698ba86962d10d927d7ac4eb781e05e33f08c9eb (patch)
tree0c014c388a52c8eb571f548227696bd6e638178f /tools/render-test/render-d3d12.cpp
parent8d77db3c4e357329c8693457d37b99fc1f48a9f7 (diff)
1st stage renderer binding refactor (#587)
* First pass at support for textures in vulkan. * Binding state has first pass support for VkImageView VkSampler. * Split out _calcImageViewType * Fix bug in debug build around constant buffer being added but not part of the binding description for the test. * Offset recalculated for vk texture construction just store the texture size for each mip level. * When outputing a vector type with a size of 1 in GLSL, it needs to be output as the underlying type. For example vector<float,1> should be output as float in GLSL. * Vulkan render-test produces right output for the test tests/compute/textureSamplingTest.slang -slang -gcompute -o tests/compute/textureSamplingTest.slang.actual.txt -vk * Small improvement around xml encoding a string. * More generalized test synthesis. * Fix image usage flags for Vulkan. * Improvements to what gets synthesized vulkan tests. * Do transition on all mip levels. * Fixing problems appearing from vulkan debug layer. * Disable Vulkan synthesized tests for now. * Add Resource::Type member to Resource::DescBase. * Removed the CompactIndexSlice from binding. Just bind the indices needed. * BindingRegister -> RegisterSet * RegisterSet -> RegisterRange * Typo fix for debug build. * Remove comment that no longer applied.
Diffstat (limited to 'tools/render-test/render-d3d12.cpp')
-rw-r--r--tools/render-test/render-d3d12.cpp31
1 files changed, 16 insertions, 15 deletions
diff --git a/tools/render-test/render-d3d12.cpp b/tools/render-test/render-d3d12.cpp
index a582e3feb..691ab7d25 100644
--- a/tools/render-test/render-d3d12.cpp
+++ b/tools/render-test/render-d3d12.cpp
@@ -57,7 +57,7 @@ public:
virtual void setClearColor(const float color[4]) override;
virtual void clearFrame() override;
virtual void presentFrame() override;
- virtual TextureResource* createTextureResource(Resource::Type type, Resource::Usage initialUsage, const TextureResource::Desc& desc, const TextureResource::Data* initData) override;
+ virtual TextureResource* createTextureResource(Resource::Usage initialUsage, const TextureResource::Desc& desc, const TextureResource::Data* initData) override;
virtual BufferResource* createBufferResource(Resource::Usage initialUsage, const BufferResource::Desc& bufferDesc, const void* initData) override;
virtual SlangResult captureScreenSurface(Surface& surfaceOut) override;
virtual InputLayout* createInputLayout(const InputElementDesc* inputElements, UInt inputElementCount) override;
@@ -178,8 +178,8 @@ protected:
public:
typedef TextureResource Parent;
- TextureResourceImpl(Type type, const Desc& desc):
- Parent(type, desc)
+ TextureResourceImpl(const Desc& desc):
+ Parent(desc)
{
}
@@ -198,7 +198,6 @@ protected:
int m_srvIndex = -1;
int m_uavIndex = -1;
int m_samplerIndex = -1;
- int m_binding = 0;
};
class BindingStateImpl: public BindingState
@@ -1089,6 +1088,8 @@ Result D3D12Renderer::_calcBindParameters(BindParameters& params)
const auto& binding = bindings[i];
const auto& detail = details[i];
+ const int bindingIndex = binding.registerRange.getSingleIndex();
+
if (binding.bindingType == BindingType::Buffer)
{
assert(binding.resource && binding.resource->isBuffer());
@@ -1102,7 +1103,7 @@ Result D3D12Renderer::_calcBindParameters(BindParameters& params)
param.ShaderVisibility = D3D12_SHADER_VISIBILITY_ALL;
D3D12_ROOT_DESCRIPTOR& descriptor = param.Descriptor;
- descriptor.ShaderRegister = detail.m_binding;
+ descriptor.ShaderRegister = bindingIndex;
descriptor.RegisterSpace = 0;
numConstantBuffers++;
@@ -1115,7 +1116,7 @@ Result D3D12Renderer::_calcBindParameters(BindParameters& params)
range.RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_SRV;
range.NumDescriptors = 1;
- range.BaseShaderRegister = detail.m_binding;
+ range.BaseShaderRegister = bindingIndex;
range.RegisterSpace = 0;
range.OffsetInDescriptorsFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND;
@@ -1135,7 +1136,7 @@ Result D3D12Renderer::_calcBindParameters(BindParameters& params)
range.RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_UAV;
range.NumDescriptors = 1;
- range.BaseShaderRegister = detail.m_binding;
+ range.BaseShaderRegister = bindingIndex;
range.RegisterSpace = 0;
range.OffsetInDescriptorsFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND;
@@ -1750,13 +1751,13 @@ static D3D12_RESOURCE_DIMENSION _calcResourceDimension(Resource::Type type)
}
}
-TextureResource* D3D12Renderer::createTextureResource(Resource::Type type, Resource::Usage initialUsage, const TextureResource::Desc& descIn, const TextureResource::Data* initData)
+TextureResource* D3D12Renderer::createTextureResource(Resource::Usage initialUsage, const TextureResource::Desc& descIn, const TextureResource::Data* initData)
{
// Description of uploading on Dx12
// https://msdn.microsoft.com/en-us/library/windows/desktop/dn899215%28v=vs.85%29.aspx
TextureResource::Desc srcDesc(descIn);
- srcDesc.setDefaults(type, initialUsage);
+ srcDesc.setDefaults(initialUsage);
const DXGI_FORMAT pixelFormat = D3DUtil::getMapFormat(srcDesc.format);
if (pixelFormat == DXGI_FORMAT_UNKNOWN)
@@ -1764,9 +1765,9 @@ TextureResource* D3D12Renderer::createTextureResource(Resource::Type type, Resou
return nullptr;
}
- const int arraySize = srcDesc.calcEffectiveArraySize(type);
+ const int arraySize = srcDesc.calcEffectiveArraySize();
- const D3D12_RESOURCE_DIMENSION dimension = _calcResourceDimension(type);
+ const D3D12_RESOURCE_DIMENSION dimension = _calcResourceDimension(srcDesc.type);
if (dimension == D3D12_RESOURCE_DIMENSION_UNKNOWN)
{
return nullptr;
@@ -1791,7 +1792,7 @@ TextureResource* D3D12Renderer::createTextureResource(Resource::Type type, Resou
resourceDesc.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN;
resourceDesc.Alignment = 0;
- RefPtr<TextureResourceImpl> texture(new TextureResourceImpl(type, srcDesc));
+ RefPtr<TextureResourceImpl> texture(new TextureResourceImpl(srcDesc));
// Create the target resource
{
@@ -2297,8 +2298,8 @@ BindingState* D3D12Renderer::createBindingState(const BindingState::Desc& bindin
const auto& srcEntry = srcBindings[i];
auto& dstDetail = dstDetails[i];
- dstDetail.m_binding = bindingStateDesc.getFirst(BindingState::ShaderStyle::Hlsl, srcEntry.shaderBindSet);
-
+ const int bindingIndex = srcEntry.registerRange.getSingleIndex();
+
switch (srcEntry.bindingType)
{
case BindingType::Buffer:
@@ -2405,7 +2406,7 @@ BindingState* D3D12Renderer::createBindingState(const BindingState::Desc& bindin
{
const BindingState::SamplerDesc& samplerDesc = bindingStateDesc.m_samplerDescs[srcEntry.descIndex];
- const int samplerIndex = bindingStateDesc.getFirst(BindingState::ShaderStyle::Hlsl, srcEntry.shaderBindSet);
+ const int samplerIndex = bindingIndex;
dstDetail.m_samplerIndex = samplerIndex;
bindingState->m_samplerHeap.placeAt(samplerIndex);