diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2018-04-19 17:47:04 -0400 |
|---|---|---|
| committer | Tim Foley <tfoleyNV@users.noreply.github.com> | 2018-04-19 14:47:04 -0700 |
| commit | 4c751df1680c30fac0369171a9b8dd4bb5bb5b9f (patch) | |
| tree | afde05a4cefd2b203add6b6ea8b94722d9734e11 /tools/render-test/render.cpp | |
| parent | cbedf01cc53b848dfcc086f04098ef438121a7c7 (diff) | |
Separation of Binding/Resource construction on Renderer interface (#508)
* Dx12 rendering works in test framework.
* Turn on dx12 render tests.
* First pass at Resource and TextureResource/BufferResource types.
* Fix bug in Dx11 impl for BufferResource.
* Dx12 supports TextureResource and binds using TextureResource type, and all tests pass.
* Added TextureBuffer::Size type to make handling mips a little simpler.
* Small improvements to Dx12 constant buffer binding
Removed k prefix on an enum
* First pass impl of dx11 createTextureResource
Added setDefaults to TextureResource::Desc and BufferResource::Desc to simplify setup
accessFlags -> cpuAccessFlags
desc -> srcDesc
* Split out generateTextureResource - can produce the texture using createTextureResource on the Renderer.
* Added support for read mapping to Dx11
accessFlags -> cpuAccessFlags
First pass at using TextureResource/BufferResource on Dx11
Some tests fail with this checkin
* TextureResource working on all tests on dx11.
* Construct ResourceBuffers on Dx11 and Dx12 using utility function createInputBufferResource.
* First pass at OpenGl TextureResource
* Small fixes to dx12 and dx11 setup.
Gl working working using BufferResource and TextureResource
* Tidy up around the compareSampler - looks like the previous test was incorrect.
* Small documentation /naming improvements.
* Fix some more small documentation issues.
* First pass testing out construction of binding resources external to Renderer implementation.
* Moved some BindingState::Desc types to BindingState to make easier to use.
* First pass of binding using BindingState::Desc for Dx11.
* First pass at binding with dx12.
* Fixed issues around separating dx12 binding from ShaderInputLayout
* First pass at OpenGl state binding.
* BindingState::Desc::Binding::Type -> BindingType
* Use Buffer to manage life of vk resources.
Construction of buffers handled by createBufferResource (BindingState doesn't have specialized logic)
* Remove InputLayout types from binding so can create a binding independent of it.
* Added upload buffer to BufferResource - could be used for write mapping.
* m_samplers -> m_samplerDescs.
First pass at Vk binding with BindingState::Desc.
Small tidy/doc improvements.
* First pass with binding all taking place through BindingState::Desc. All tests pass.
* Removed support for creating BindingState from ShaderInputLayout
* Remove serializeOutput from Renderer interface and all implementations.
Implement map/unmap on vulkan
Implement serializeBindingOutput which uses map/unmap and BindingState::Desc to write result.
* Make implementation of BindingState use the BindingState::Desc for much of state - only hold api specific in BindingDetail per implementation.
* Use Glsl binding on vulkan (was using hlsl).
* BindingState::Desc::Binding -> BindingState::Binding. Made possible by impls using 'BindingDetail' for their specific needs.
* Fix compile problems on win32.
* Fix a typo in name createBindingSetDesc -> createBindingStateDesc
Diffstat (limited to 'tools/render-test/render.cpp')
| -rw-r--r-- | tools/render-test/render.cpp | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/tools/render-test/render.cpp b/tools/render-test/render.cpp index 292aa75f7..3346317e7 100644 --- a/tools/render-test/render.cpp +++ b/tools/render-test/render.cpp @@ -21,6 +21,134 @@ using namespace Slang; BindFlag::Enum(BindFlag::PixelShaderResource | BindFlag::NonPixelShaderResource), // GenericRead }; +static const Resource::DescBase s_emptyDescBase = {}; + +const Resource::DescBase& Resource::getDescBase() const +{ + if (isBuffer()) + { + return static_cast<const BufferResource *>(this)->getDesc(); + } + else if (isTexture()) + { + return static_cast<const TextureResource *>(this)->getDesc(); + } + return s_emptyDescBase; +} + +/* !!!!!!!!!!!!!!!!!!!!!!!!!!! BindingState::Desc !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ + +void BindingState::Desc::addSampler(const SamplerDesc& desc, const RegisterDesc& registerDesc) +{ + int descIndex = int(m_samplerDescs.Count()); + m_samplerDescs.Add(desc); + + Binding binding; + binding.bindingType = BindingType::Sampler; + binding.resource = nullptr; + binding.registerDesc = registerDesc; + binding.descIndex = descIndex; + + m_bindings.Add(binding); +} + +void BindingState::Desc::addResource(BindingType bindingType, Resource* resource, const RegisterDesc& registerDesc) +{ + assert(resource); + + Binding binding; + binding.bindingType = bindingType; + binding.resource = resource; + binding.descIndex = -1; + binding.registerDesc = registerDesc; + m_bindings.Add(binding); +} + +void BindingState::Desc::addCombinedTextureSampler(TextureResource* resource, const SamplerDesc& samplerDesc, const RegisterDesc& registerDesc) +{ + assert(resource); + + int samplerDescIndex = int(m_samplerDescs.Count()); + m_samplerDescs.Add(samplerDesc); + + Binding binding; + binding.bindingType = BindingType::CombinedTextureSampler; + binding.resource = resource; + binding.descIndex = samplerDescIndex; + binding.registerDesc = registerDesc; + m_bindings.Add(binding); +} + +BindingState::RegisterSet BindingState::Desc::addRegisterSet(int index) +{ + if (index < 0) + { + return RegisterSet(); + } + return RegisterSet(index, 1); +} + +BindingState::RegisterSet BindingState::Desc::addRegisterSet(const int* srcIndices, int numIndices) +{ + assert(numIndices >= 0); + switch (numIndices) + { + case 0: return RegisterSet(); + case 1: return RegisterSet(srcIndices[0], 1); + default: + { + int startIndex = int(m_indices.Count()); + m_indices.SetSize(startIndex + numIndices); + uint16_t* dstIndices = m_indices.Buffer() + startIndex; + for (int i = 0; i < numIndices; i++) + { + assert(srcIndices[i] >= 0); + dstIndices[i] = uint16_t(srcIndices[i]); + } + return RegisterSet(startIndex, numIndices); + } + } +} + +int BindingState::Desc::getFirst(const RegisterSet& set) const +{ + switch (set.m_numIndices) + { + case 0: return -1; + case 1: return set.m_indexOrBase; + default: return m_indices[set.m_indexOrBase]; + } +} + +int BindingState::Desc::getFirst(ShaderStyle style, const RegisterDesc& registerDesc) const +{ + return getFirst(registerDesc.registerSets[int(style)]); +} + +void BindingState::Desc::clear() +{ + m_bindings.Clear(); + m_samplerDescs.Clear(); + m_indices.Clear(); + m_numRenderTargets = 1; +} + +BindingState::RegisterList BindingState::Desc::asRegisterList(const RegisterSet& set) const +{ + switch (set.m_numIndices) + { + case 0: return RegisterList{ nullptr, 0 }; + case 1: return RegisterList{ &set.m_indexOrBase, 1 }; + default: return RegisterList{ m_indices.Buffer() + set.m_indexOrBase, set.m_numIndices }; + } +} + +BindingState::RegisterList BindingState::Desc::asRegisterList(ShaderStyle style, const RegisterDesc& registerDesc) const +{ + return asRegisterList(registerDesc.registerSets[int(style)]); +} + + /* !!!!!!!!!!!!!!!!!!!!!!!!!!! TextureResource::Size !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ int TextureResource::Size::calcMaxDimension(Type type) const |
