30 #include "DeviceObjectBase.h" 31 #include "STDAllocator.h" 32 #include "PlatformMisc.h" 33 #include "EngineMemory.h" 38 inline SHADER_TYPE GetShaderTypeFromIndex( Int32 Index )
45 Int32 ShaderIndex = PlatformMisc::GetLSB(Type);
57 default: UNEXPECTED(
"Unexpected shader type (", Type,
")" );
break;
59 VERIFY( Type == GetShaderTypeFromIndex(ShaderIndex),
"Incorrect shader type index" );
71 template<
typename TNameCompare>
74 for (Uint32 v = 0; v < NumVars; ++v)
76 const auto &CurrVarDesc = VariableDesc[v];
77 if ( NameCompare(CurrVarDesc.Name) )
79 return CurrVarDesc.Type;
82 return DefaultVariableType;
87 return GetShaderVariableType(DefaultVariableType, VariableDesc, NumVars,
88 [&](
const char *VarName)
90 return strcmp(VarName, Name) == 0;
113 virtual IReferenceCounters* GetReferenceCounters()
const override final 115 return m_Owner.GetReferenceCounters();
118 virtual Atomics::Long AddRef()
override final 120 return m_Owner.AddRef();
123 virtual Atomics::Long Release()
override final 125 return m_Owner.Release();
128 virtual void QueryInterface(
const INTERFACE_ID &IID, IObject **ppInterface )
override final 130 if( ppInterface ==
nullptr )
133 *ppInterface =
nullptr;
134 if( IID == IID_ShaderVariable || IID == IID_Unknown )
137 (*ppInterface)->AddRef();
171 template<
class BaseInterface,
class RenderDeviceBaseInterface>
186 m_StringPool(ShdrDesc.NumVariables + ShdrDesc.NumStaticSamplers, String(), STD_ALLOCATOR_RAW_MEM(String,
GetRawAllocator(),
"Allocator for vector<String>")),
195 VERIFY(
m_VariablesDesc[v].Name !=
nullptr,
"Variable name not provided");
206 VERIFY(
m_StaticSamplers[s].TextureName !=
nullptr,
"Static sampler texture name not provided");
211 if( !( (BorderColor[0] == 0 && BorderColor[1] == 0 && BorderColor[2] == 0 && BorderColor[3] == 0) ||
212 (BorderColor[0] == 0 && BorderColor[1] == 0 && BorderColor[2] == 0 && BorderColor[3] == 1) ||
213 (BorderColor[0] == 1 && BorderColor[1] == 1 && BorderColor[2] == 1 && BorderColor[3] == 0) ) )
215 LOG_WARNING_MESSAGE(
"Static sampler for variable \"", *Str ,
"\" specifies border color (", BorderColor[0],
", ", BorderColor[1],
", ", BorderColor[2],
", ", BorderColor[3],
"). D3D12 static samplers only allow transparent black (0,0,0,1), opaque black (0,0,0,0) or opaque white (1,1,1,0) as border colors");
225 IMPLEMENT_QUERY_INTERFACE_IN_PLACE( IID_Shader, TDeviceObjectBase )
231 std::vector<ShaderVariableDesc, STDAllocatorRawMem<ShaderVariableDesc> >
m_VariablesDesc;
Render device interface.
Definition: RenderDevice.h:55
virtual void SetArray(IDeviceObject *const *ppObjects, Uint32 FirstElement, Uint32 NumElements) override final
Sets the variable array.
Definition: ShaderBase.h:158
Base interface for all objects created by the render device Diligent::IRenderDevice.
Definition: DeviceObject.h:40
Shader resource variable.
Definition: Shader.h:265
const StaticSamplerDesc * StaticSamplers
Array of static sampler descriptions.
Definition: Shader.h:175
Shader description.
Definition: Shader.h:152
SHADER_TYPE
Describes the shader type.
Definition: Shader.h:46
Namespace for the OpenGL implementation of the graphics engine.
Definition: BufferD3D11Impl.h:34
Pixel (fragment) shader.
Definition: Shader.h:50
Static sampler description.
Definition: Shader.h:136
Template class implementing base functionality for a shader object.
Definition: ShaderBase.h:172
IMemoryAllocator & GetRawAllocator()
Returns raw memory allocator.
Definition: EngineMemory.cpp:46
Hull (tessellation control) shader.
Definition: Shader.h:52
Domain (tessellation evaluation) shader.
Definition: Shader.h:53
std::vector< ShaderVariableDesc, STDAllocatorRawMem< ShaderVariableDesc > > m_VariablesDesc
Shader variable descriptions.
Definition: ShaderBase.h:231
Implementation of a dummy shader variable that silently ignores all operations.
Definition: ShaderBase.h:146
Describes shader variable.
Definition: Shader.h:121
SHADER_VARIABLE_TYPE
Describes shader variable type that is used by ShaderVariableDesc.
Definition: Shader.h:100
Vertex shader.
Definition: Shader.h:49
Unknown shader type.
Definition: Shader.h:48
ShaderDesc m_Desc
Object description.
Definition: DeviceObjectBase.h:138
ShaderBase(IReferenceCounters *pRefCounters, IRenderDevice *pDevice, const ShaderDesc &ShdrDesc, bool bIsDeviceInternal=false)
Definition: ShaderBase.h:182
std::vector< StaticSamplerDesc, STDAllocatorRawMem< StaticSamplerDesc > > m_StaticSamplers
Static sampler descriptions.
Definition: ShaderBase.h:235
const ShaderVariableDesc * VariableDesc
Array of shader variable descriptions.
Definition: Shader.h:166
Base implementation of a shader variable.
Definition: ShaderBase.h:98
Template class implementing base functionality for a device object.
Definition: DeviceObjectBase.h:42
Uint32 NumVariables
Number of elements in VariableDesc array.
Definition: Shader.h:169
virtual void Set(IDeviceObject *pObject) override final
Sets the variable to the given value.
Definition: ShaderBase.h:152
DummyShaderVariable m_DummyShaderVar
Dummy shader variable.
Definition: ShaderBase.h:228
Compute shader.
Definition: Shader.h:54
std::vector< String, STDAllocatorRawMem< String > > m_StringPool
String pool that is used to hold copies of variable names and static sampler names.
Definition: ShaderBase.h:233
Uint32 NumStaticSamplers
Number of static samplers in StaticSamplers array.
Definition: Shader.h:172
Geometry shader.
Definition: Shader.h:51