diff options
| author | lucy96chen <47800040+lucy96chen@users.noreply.github.com> | 2022-07-27 15:53:36 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-27 15:53:36 -0700 |
| commit | ed37dcbc175d07134cb0493f5e379a19e97c82f5 (patch) | |
| tree | 0abd3202401d89e76a979ab7c18569afd63db8a6 /tools/gfx/cpu/cpu-shader-object.h | |
| parent | de0f8cf1be0770b87a117b637943db4ad4e1158b (diff) | |
Split render-cpu into smaller files (#2340)
* render-cpu split, does not compile
* split finished, one compile error
* added missing include and missing destructor implementation
* Rerun TeamCity CI
Diffstat (limited to 'tools/gfx/cpu/cpu-shader-object.h')
| -rw-r--r-- | tools/gfx/cpu/cpu-shader-object.h | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/tools/gfx/cpu/cpu-shader-object.h b/tools/gfx/cpu/cpu-shader-object.h new file mode 100644 index 000000000..5d0b5c366 --- /dev/null +++ b/tools/gfx/cpu/cpu-shader-object.h @@ -0,0 +1,98 @@ +// cpu-shader-object.h +#pragma once +#include "cpu-base.h" + +#include "cpu-shader-object-layout.h" + +namespace gfx +{ +using namespace Slang; + +namespace cpu +{ + +class CPUShaderObjectData +{ +public: + Slang::List<char> m_ordinaryData; + // Any "ordinary" / uniform data for this object + Slang::RefPtr<BufferResourceImpl> m_bufferResource; + Slang::RefPtr<BufferResourceViewImpl> m_bufferView; + + Index getCount(); + void setCount(Index count); + char* getBuffer(); + + ~CPUShaderObjectData(); + + /// Returns a StructuredBuffer resource view for GPU access into the buffer content. + /// Creates a StructuredBuffer resource if it has not been created. + ResourceViewBase* getResourceView( + RendererBase* device, + slang::TypeLayoutReflection* elementLayout, + slang::BindingType bindingType); +}; + +class ShaderObjectImpl + : public ShaderObjectBaseImpl<ShaderObjectImpl, ShaderObjectLayoutImpl, CPUShaderObjectData> +{ + typedef ShaderObjectBaseImpl<ShaderObjectImpl, ShaderObjectLayoutImpl, CPUShaderObjectData> Super; + +public: + List<RefPtr<ResourceViewImpl>> m_resources; + + virtual SLANG_NO_THROW Result SLANG_MCALL + init(IDevice* device, ShaderObjectLayoutImpl* typeLayout); + + virtual SLANG_NO_THROW GfxCount SLANG_MCALL getEntryPointCount() override; + virtual SLANG_NO_THROW Result SLANG_MCALL + getEntryPoint(GfxIndex index, IShaderObject** outEntryPoint) override; + + virtual SLANG_NO_THROW const void* SLANG_MCALL getRawData() override; + + virtual SLANG_NO_THROW size_t SLANG_MCALL getSize() override; + + virtual SLANG_NO_THROW Result SLANG_MCALL + setData(ShaderOffset const& offset, void const* data, size_t size) override; + virtual SLANG_NO_THROW Result SLANG_MCALL + setResource(ShaderOffset const& offset, IResourceView* inView) override; + virtual SLANG_NO_THROW Result SLANG_MCALL + setObject(ShaderOffset const& offset, IShaderObject* object) override; + virtual SLANG_NO_THROW Result SLANG_MCALL + setSampler(ShaderOffset const& offset, ISamplerState* sampler) override; + virtual SLANG_NO_THROW Result SLANG_MCALL setCombinedTextureSampler( + ShaderOffset const& offset, IResourceView* textureView, ISamplerState* sampler) override; + + char* getDataBuffer(); +}; + +class MutableShaderObjectImpl : public MutableShaderObject<MutableShaderObjectImpl, ShaderObjectLayoutImpl> +{}; + +class EntryPointShaderObjectImpl : public ShaderObjectImpl +{ +public: + EntryPointLayoutImpl* getLayout(); +}; + +class RootShaderObjectImpl : public ShaderObjectImpl +{ +public: + virtual SLANG_NO_THROW uint32_t SLANG_MCALL addRef() override; + virtual SLANG_NO_THROW uint32_t SLANG_MCALL release() override; + + Result init(IDevice* device, RootShaderObjectLayoutImpl* programLayout); + + RootShaderObjectLayoutImpl* getLayout(); + + EntryPointShaderObjectImpl* getEntryPoint(Index index); + List<RefPtr<EntryPointShaderObjectImpl>> m_entryPoints; + + virtual SLANG_NO_THROW GfxCount SLANG_MCALL getEntryPointCount() override; + virtual SLANG_NO_THROW Result SLANG_MCALL + getEntryPoint(GfxIndex index, IShaderObject** outEntryPoint) override; + virtual Result collectSpecializationArgs(ExtendedShaderObjectTypeList& args) override; +}; + +} // namespace cpu +} // namespace gfx |
