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/gfx/render.h | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) (limited to 'tools/gfx/render.h') diff --git a/tools/gfx/render.h b/tools/gfx/render.h index 053f9e1e2..7b77650e8 100644 --- a/tools/gfx/render.h +++ b/tools/gfx/render.h @@ -840,14 +840,6 @@ struct ShaderOffset SlangInt bindingArrayIndex = 0; }; -class IShaderObjectLayout : public ISlangUnknown -{}; -#define SLANG_UUID_IShaderObjectLayout \ - { \ - 0x27f3f67e, 0xa49d, 0x4aae, { 0xa6, 0xd, 0xfa, 0xc2, 0x6b, 0x1c, 0x10, 0x7c } \ - } - - class IShaderObject : public ISlangUnknown { public: @@ -1220,22 +1212,12 @@ public: return layout; } - virtual SLANG_NO_THROW Result SLANG_MCALL createShaderObjectLayout( - slang::TypeLayoutReflection* typeLayout, IShaderObjectLayout** outLayout) = 0; - - inline ComPtr createShaderObjectLayout(slang::TypeLayoutReflection* typeLayout) - { - ComPtr layout; - SLANG_RETURN_NULL_ON_FAIL(createShaderObjectLayout(typeLayout, layout.writeRef())); - return layout; - } - - virtual SLANG_NO_THROW Result SLANG_MCALL createShaderObject(IShaderObjectLayout* layout, IShaderObject** outObject) = 0; + virtual SLANG_NO_THROW Result SLANG_MCALL createShaderObject(slang::TypeReflection* type, IShaderObject** outObject) = 0; - inline ComPtr createShaderObject(IShaderObjectLayout* layout) + inline ComPtr createShaderObject(slang::TypeReflection* type) { ComPtr object; - SLANG_RETURN_NULL_ON_FAIL(createShaderObject(layout, object.writeRef())); + SLANG_RETURN_NULL_ON_FAIL(createShaderObject(type, object.writeRef())); return object; } -- cgit v1.2.3