diff options
| author | Yong He <yonghe@outlook.com> | 2021-10-18 12:19:45 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-18 12:19:45 -0700 |
| commit | 2f44d9e01234911dd563f0456b9d861fd8db286d (patch) | |
| tree | e2727f31654ebc93bae6a1de4b25586be6fb9d10 /tools/gfx/open-gl/render-gl.cpp | |
| parent | 87e7c49fbfccd54be0d1cee61fba8f309b1f792e (diff) | |
GFX: implement mutable shader objects. (#1963)
* GFX: implement mutable shader objects.
* Revert unnecessary changes
* Revert more changes.
* Fix clang errors.
* Fix clang/gcc errors.
* Fix clang errors.
* Remove CPU test.
* Fix after merge.
* Fix after merge.
* Remove gl test
* Code review fixes.
* Fixing all vk validation errors.
* Flush test output more often.
* Fix a crash in `specializeDynamicAssociatedTypeLookup`.
* temporarily disable std-lib-serialize test to see what happens
* Fix crashes.
* Make sure cpu gfx unit tests are properly disabled on TeamCity.
* Disable cpu test.
* Fix.
* Fix cuda.
* Disable nv-ray-tracing-motion-blur
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'tools/gfx/open-gl/render-gl.cpp')
| -rw-r--r-- | tools/gfx/open-gl/render-gl.cpp | 47 |
1 files changed, 20 insertions, 27 deletions
diff --git a/tools/gfx/open-gl/render-gl.cpp b/tools/gfx/open-gl/render-gl.cpp index 9ad24146d..a5d5ae368 100644 --- a/tools/gfx/open-gl/render-gl.cpp +++ b/tools/gfx/open-gl/render-gl.cpp @@ -4,6 +4,7 @@ #include "../nvapi/nvapi-util.h" #include "../immediate-renderer-base.h" +#include "../mutable-shader-object.h" #include "core/slang-basic.h" #include "core/slang-blob.h" @@ -140,6 +141,7 @@ public: slang::TypeLayoutReflection* typeLayout, ShaderObjectLayoutBase** outLayout) override; virtual Result createShaderObject(ShaderObjectLayoutBase* layout, IShaderObject** outObject) override; + virtual Result createMutableShaderObject(ShaderObjectLayoutBase* layout, IShaderObject** outObject) override; virtual Result createRootShaderObject(IShaderProgram* program, ShaderObjectBase** outObject) override; virtual void bindRootShaderObject(IShaderObject* shaderObject) override; @@ -283,17 +285,9 @@ public: GLuint m_handle; }; - class SamplerStateImpl : public ISamplerState, public ComObject + class SamplerStateImpl : public SamplerStateBase { public: - SLANG_COM_OBJECT_IUNKNOWN_ALL - ISamplerState* getInterface(const Guid& guid) - { - if (guid == GfxGUID::IID_ISlangUnknown || guid == GfxGUID::IID_ISamplerState) - return static_cast<ISamplerState*>(this); - return nullptr; - } - public: GLuint m_samplerID; }; @@ -340,20 +334,9 @@ public: IFramebufferLayout::AttachmentLayout m_depthStencil; }; - class FramebufferImpl - : public IFramebuffer - , public ComObject + class FramebufferImpl : public FramebufferBase { public: - SLANG_COM_OBJECT_IUNKNOWN_ALL - IFramebuffer* getInterface(const Guid& guid) - { - if (guid == GfxGUID::IID_ISlangUnknown || guid == GfxGUID::IID_IFramebuffer) - return static_cast<IFramebuffer*>(this); - return nullptr; - } - - public: GLuint m_framebuffer; ShortList<GLenum> m_drawBuffers; RefPtr<WeakSink<GLDevice>> m_renderer; @@ -1394,16 +1377,15 @@ public: RefPtr<ShaderObjectLayoutImpl> m_specializedLayout; }; + class MutableShaderObjectImpl : public MutableShaderObject<MutableShaderObjectImpl, ShaderObjectLayoutImpl> + {}; + class RootShaderObjectImpl : public ShaderObjectImpl { typedef ShaderObjectImpl Super; - public: - // Override default reference counting behavior to disable lifetime management via ComPtr. - // Root objects are managed by command buffer and does not need to be freed by the user. - SLANG_NO_THROW uint32_t SLANG_MCALL addRef() override { return 1; } - SLANG_NO_THROW uint32_t SLANG_MCALL release() override { return 1; } - + virtual SLANG_NO_THROW uint32_t SLANG_MCALL addRef() override { return 1; } + virtual SLANG_NO_THROW uint32_t SLANG_MCALL release() override { return 1; } public: static Result create(IDevice* device, RootShaderObjectLayoutImpl* layout, RootShaderObjectImpl** outShaderObject) { @@ -2845,6 +2827,17 @@ Result GLDevice::createShaderObject(ShaderObjectLayoutBase* layout, IShaderObjec return SLANG_OK; } +Result GLDevice::createMutableShaderObject(ShaderObjectLayoutBase* layout, IShaderObject** outObject) +{ + auto layoutImpl = static_cast<ShaderObjectLayoutImpl*>(layout); + + RefPtr<MutableShaderObjectImpl> result = new MutableShaderObjectImpl(); + SLANG_RETURN_ON_FAIL(result->init(this, layoutImpl)); + returnComPtr(outObject, result); + + return SLANG_OK; +} + Result GLDevice::createRootShaderObject(IShaderProgram* program, ShaderObjectBase** outObject) { auto programImpl = static_cast<ShaderProgramImpl*>(program); |
