diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2021-03-17 12:55:30 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-17 12:55:30 -0700 |
| commit | 6e5d85efb9fa5f647f7f0c7ef784a9fd09b29023 (patch) | |
| tree | 6206ef11502a1a5d9c1dc00df359be9aececffdf /tools/render-test/shader-input-layout.cpp | |
| parent | b64a23cccfe9876d53cda773afc796bd975fa7e5 (diff) | |
Remove old code paths from render-test (#1760)
* Remove old code paths from render-test
Historically, the `render-test` tool was using three different code paths:
* One based on `gfx` and manual (non-reflection-based) parameter setting, used for OpenGL, D3D11, D3D12, and Vulkan
* One for CPU that used reflection-based parameter setting but shared no code with the first
* One for CUDA that used reflection-based parameter setting and shared some, but not all, code with the CPU path
Recently we've updated `render-test` to include a fourth option:
* Using `gfx` and the "shader object" system it exposes for a unified reflection-based parameter-setting system taht works across OpenGL, D3D11, D3D12, Vulkan, CUDA, and CPU
This change removes the first three options and leaves only the single unified path. A sa result, a bunch of code in `render-test` is no longer needed, and the codebase no longer relies on things like the `IDescriptorSet`-related APIs in `gfx`.
Several existing tests had to be disabled to make this change possible. Those tests will need to be audited and either re-enabled once we fix issues in the shader object system, or permanently removed if they don't test stuff we intend to support in the long run (e.g., global-scope type parameters, which aren't a clear necessity).
* fixup: CUDA detection logic
Diffstat (limited to 'tools/render-test/shader-input-layout.cpp')
| -rw-r--r-- | tools/render-test/shader-input-layout.cpp | 196 |
1 files changed, 1 insertions, 195 deletions
diff --git a/tools/render-test/shader-input-layout.cpp b/tools/render-test/shader-input-layout.cpp index 2f7162f35..071c694b5 100644 --- a/tools/render-test/shader-input-layout.cpp +++ b/tools/render-test/shader-input-layout.cpp @@ -631,180 +631,12 @@ 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.isBindlessObject) - continue; - - 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; - } - - /* static */void ShaderInputLayout::getValueBuffers(const Slang::List<ShaderInputLayoutEntry>& entries, const BindSet& bindSet, List<BindSet::Value*>& outBuffers) - { - outBuffers.setCount(entries.getCount()); - - for (Index i = 0; i< outBuffers.getCount(); ++i) - { - outBuffers[i] = nullptr; - } - - const auto& values = bindSet.getValues(); - for (BindSet::Value* value : values) - { - if (value->m_userIndex >= 0) - { - outBuffers[value->m_userIndex] = value; - } - } - } - - /* static */SlangResult ShaderInputLayout::writeBinding(BindRoot* bindRoot, const ShaderInputLayoutEntry& entry, const void* data, size_t sizeInBytes, WriterHelper writer) + /* static */SlangResult ShaderInputLayout::writeBinding(const ShaderInputLayoutEntry& entry, slang::TypeLayoutReflection* typeLayout, const void* data, size_t sizeInBytes, WriterHelper writer) { typedef slang::TypeReflection::ScalarType ScalarType; slang::TypeReflection::ScalarType scalarType = slang::TypeReflection::ScalarType::None; - slang::TypeLayoutReflection* typeLayout = nullptr; - - if (bindRoot && entry.name.getLength()) - { - BindLocation location; - if (SLANG_SUCCEEDED(bindRoot->parse(entry.name, "", writer, location))) - { - // We should have the type of the item - typeLayout = location.m_typeLayout; - } - } - slang::TypeLayoutReflection* elementTypeLayout = nullptr; if (typeLayout) @@ -954,32 +786,6 @@ namespace renderer_test return SLANG_OK; } - /* static */SlangResult ShaderInputLayout::writeBindings(BindRoot* bindRoot, const ShaderInputLayout& layout, const List<BindSet::Value*>& buffers, WriterHelper writer) - { - const auto& entries = layout.entries; - for (int i = 0; i < entries.getCount(); ++i) - { - const auto& entry = entries[i]; - if (entry.isOutput) - { - BindSet::Value* buffer = buffers[i]; - writeBinding(bindRoot, entries[i], buffer->m_data, buffer->m_sizeInBytes, writer); - } - } - - return SLANG_OK; - } - - /* static */SlangResult ShaderInputLayout::writeBindings(BindRoot* bindRoot, const ShaderInputLayout& layout, const List<BindSet::Value*>& buffers, const String& fileName) - { - FILE * f = fopen(fileName.getBuffer(), "wb"); - if (!f) - { - return SLANG_FAIL; - } - FileWriter fileWriter(f, WriterFlags(0)); - return writeBindings(bindRoot, layout, buffers, &fileWriter); - } void generateTextureData(TextureData& output, const InputTextureDesc& desc) { |
