diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2020-01-15 14:58:45 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-01-15 14:58:45 -0500 |
| commit | 662721ba4ab0e38924701df4c876a86eb8390968 (patch) | |
| tree | deef68220d0aebbdfff370918a3d42fcf12fd72c /tools/render-test/shader-input-layout.cpp | |
| parent | ef41dfc605f7868c0ccc7dde05982232b7d49589 (diff) | |
Bind Location (#1166)
* First pass at BindLocation.
* Added BindSet::init - for initializing with two input constant buffers. Needs better name, and perhaps should be another class.
* Fix handling of constant buffer stripping.
Improved initialization.
* Trying to generalize BindLocation a little more.
Split out CPULikeBindRoot.
* More work to make BindLocation et al work with non uniform bindings.
* Added parsing to a location.
* WIP: Trying to get CPU working with BindLocation.
* Describe problem of knowing the type of the reference point in the binding table.
* More ideas on getBindings fix.
* Remove BindSet as member of BindLocation.
* Added BindLocation::Invalid
* Made BindLocation able to be key in hash
* Use BindLocation for bindings on BindingSet.
* Added cuda and nvrtc categories to test infrastructure.
Disabled CUDA synthetic tests by default.
Fixed such that all tests now produce something in BindLocation style.
* Use m_userIndex instead of m_userData on Resource.
Move the binding setup out of cpu-compute-util (as no longer CPU specific)
* Removed CPUBinding - used BindLocation/BindSet instead.
Fixed some bugs around indexOf around uniform indirection.
* Renamed BindSet::Resource -> BindSet::Value.
* Document BindLocation.
* Fixes for Clang/GCC
Improve invariant requirement handling when constructing from BindPoints.
Diffstat (limited to 'tools/render-test/shader-input-layout.cpp')
| -rw-r--r-- | tools/render-test/shader-input-layout.cpp | 135 |
1 files changed, 135 insertions, 0 deletions
diff --git a/tools/render-test/shader-input-layout.cpp b/tools/render-test/shader-input-layout.cpp index 7a9001c9e..5ae35b90d 100644 --- a/tools/render-test/shader-input-layout.cpp +++ b/tools/render-test/shader-input-layout.cpp @@ -541,6 +541,141 @@ namespace renderer_test } } + /* static */SlangResult ShaderInputLayout::addBindSetValues(const Slang::List<ShaderInputLayoutEntry>& entries, const String& sourcePath, WriterHelper outStream, BindRoot& bindRoot) + { + BindSet* bindSet = bindRoot.getBindSet(); + SLANG_ASSERT(bindSet); + + for (Index entryIndex = 0; entryIndex < entries.getCount(); ++entryIndex) + { + auto& entry = entries[entryIndex]; + + if (entry.name.getLength() == 0) + { + outStream.print("No 'name' specified for value in '%s'\n", sourcePath.getBuffer()); + return SLANG_FAIL; + } + + BindLocation location = BindLocation::Invalid; + SLANG_RETURN_ON_FAIL(bindRoot.parse(entry.name, sourcePath, outStream, location)); + + auto& srcEntry = entries[entryIndex]; + + auto typeLayout = location.getTypeLayout(); + const auto kind = typeLayout->getKind(); + switch (kind) + { + case slang::TypeReflection::Kind::Array: + { + auto elementCount = int(typeLayout->getElementCount()); + if (elementCount == 0) + { + if (srcEntry.type == ShaderInputType::Array) + { + // Set the size + SLANG_RETURN_ON_FAIL(bindRoot.setArrayCount(location, srcEntry.arrayDesc.size)); + } + break; + } + break; + } + case slang::TypeReflection::Kind::Vector: + case slang::TypeReflection::Kind::Matrix: + case slang::TypeReflection::Kind::Scalar: + case slang::TypeReflection::Kind::Struct: + { + SLANG_RETURN_ON_FAIL(location.setUniform(srcEntry.bufferData.getBuffer(), srcEntry.bufferData.getCount() * sizeof(unsigned int))); + break; + } + default: + break; + case slang::TypeReflection::Kind::ConstantBuffer: + { + SLANG_RETURN_ON_FAIL(bindSet->setBufferContents(location, srcEntry.bufferData.getBuffer(), srcEntry.bufferData.getCount() * sizeof(unsigned int))); + break; + } + case slang::TypeReflection::Kind::ParameterBlock: + { + auto elementTypeLayout = typeLayout->getElementTypeLayout(); + SLANG_UNUSED(elementTypeLayout); + break; + } + case slang::TypeReflection::Kind::TextureBuffer: + { + auto elementTypeLayout = typeLayout->getElementTypeLayout(); + SLANG_UNUSED(elementTypeLayout); + break; + } + case slang::TypeReflection::Kind::ShaderStorageBuffer: + { + auto elementTypeLayout = typeLayout->getElementTypeLayout(); + SLANG_UNUSED(elementTypeLayout); + break; + } + case slang::TypeReflection::Kind::GenericTypeParameter: + { + const char* name = typeLayout->getName(); + SLANG_UNUSED(name); + break; + } + case slang::TypeReflection::Kind::Interface: + { + const char* name = typeLayout->getName(); + SLANG_UNUSED(name); + break; + } + case slang::TypeReflection::Kind::Resource: + { + if (BindSet::isTextureType(typeLayout)) + { + // We don't bother setting any data + BindSet::Value* value = bindSet->createTextureValue(typeLayout); + value->m_userIndex = entryIndex; + bindSet->setAt(location, value); + break; + } + + auto type = typeLayout->getType(); + auto shape = type->getResourceShape(); + + //auto access = type->getResourceAccess(); + + switch (shape & SLANG_RESOURCE_BASE_SHAPE_MASK) + { + default: + assert(!"unhandled case"); + break; + case SLANG_BYTE_ADDRESS_BUFFER: + case SLANG_STRUCTURED_BUFFER: + { + size_t bufferSize = srcEntry.bufferData.getCount() * sizeof(unsigned int); + + BindSet::Value* value = bindSet->createBufferValue(typeLayout, bufferSize, srcEntry.bufferData.getBuffer()); + SLANG_ASSERT(value); + + value->m_userIndex = entryIndex; + + bindSet->setAt(location, value); + break; + } + } + if (shape & SLANG_TEXTURE_ARRAY_FLAG) + { + + } + if (shape & SLANG_TEXTURE_MULTISAMPLE_FLAG) + { + + } + + break; + } + } + } + + return SLANG_OK; + } + void generateTextureData(TextureData& output, const InputTextureDesc& desc) { switch (desc.format) |
