From b1e376fa1e7dd0ff59991bdf1d3d859d3b63a74a Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Wed, 17 Feb 2021 18:42:23 -0800 Subject: Streamline shader object creation (#1717) This change kind of rolls together two different simplifications: 1. The `createShaderObject()` shouldn't really need to take an `IShaderObjectLayout` because it could just take the `slang::TypeLayoutReflection` instead and create the shader-object layout behind the scenes. 2. For that matter, it needn't take a `slang::TypeLayoutReflection` either, becaues it could just take a `slang::TypeReflection` and query the layout of that type behind the scenes. The combination of these two changes means: * `IShaderObjectLayout` is gone from the public API, as is `createShaderObjectLayout()` * `createShaderObject()` directly takes a `slang::TypeReflection` and allocates a shader object of that type The result is simpler and more streamlined application code. Note that under the hood the implementation still has shader-object layouts, using the `ShaderObjectLayoutBase` class. A few locations had to change to use `RefPtr`s instead of `ComPtr`s now that the class is no longer a public COM-lite API type. The hope is that this change makes it easier to allocate/cache layouts for things like specialized types "under the hood," as is needed to implement parameter setting for static specialization. --- tools/render-test/render-test-main.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'tools/render-test/render-test-main.cpp') diff --git a/tools/render-test/render-test-main.cpp b/tools/render-test/render-test-main.cpp index e57e3917e..8f62d8a50 100644 --- a/tools/render-test/render-test-main.cpp +++ b/tools/render-test/render-test-main.cpp @@ -397,14 +397,13 @@ SlangResult _assignVarsFromLayout( case ShaderInputType::Object: { auto typeName = entry.objectDesc.typeName; - slang::TypeLayoutReflection* slangTypeLayout = nullptr; + slang::TypeReflection* slangType = nullptr; if(typeName.getLength() != 0) { // If the input line specified the name of the type // to allocate, then we use it directly. // - auto slangType = slangReflection->findTypeByName(typeName.getBuffer()); - slangTypeLayout = slangReflection->getTypeLayout(slangType); + slangType = slangReflection->findTypeByName(typeName.getBuffer()); } else { @@ -412,7 +411,7 @@ SlangResult _assignVarsFromLayout( // then we will infer the type from the type of the // value pointed to by `entryCursor`. // - slangTypeLayout = entryCursor.getTypeLayout(); + auto slangTypeLayout = entryCursor.getTypeLayout(); switch(slangTypeLayout->getKind()) { default: @@ -428,11 +427,11 @@ SlangResult _assignVarsFromLayout( slangTypeLayout = slangTypeLayout->getElementTypeLayout(); break; } + slangType = slangTypeLayout->getType(); } - ComPtr shaderObjectLayout = renderer->createShaderObjectLayout(slangTypeLayout); ComPtr shaderObject = - renderer->createShaderObject(shaderObjectLayout); + renderer->createShaderObject(slangType); entryCursor.setObject(shaderObject); } -- cgit v1.2.3