Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct StateGroup
- {
- u32 SizeInBytes();
- void Release();
- };
- typedef bool bool4[4];
- struct DepthStencilState
- {
- struct DepthState
- {
- bool enable, write;
- ComparisonFunc::Type func;
- bool depthBoundsTest;
- float depthBoundsMin, depthBoundsMax;
- } depth;
- struct StencilState
- {
- bool enable, twoSided;
- u8 ref, writeMask, readMask;
- struct Face
- {
- ComparisonFunc::Type func;
- StencilOperation::Type pass;
- StencilOperation::Type fail;
- StencilOperation::Type zFail;
- } front, back;
- } stencil;
- };
- struct BlendState
- {
- bool4 writeMask;
- bool blendEnable;
- bool separateAlpha;
- struct BlendConfig
- {
- BlendFactor::Type src;
- BlendFactor::Type dst;
- BlendEquation::Type op;
- } color, alpha;
- Color4f constant;
- u32 customSampleMask;//0 is treated as 0xffffffff
- bool alphaToCoverage;
- };
- struct MrtBlendState
- {
- u32 numTargets;
- bool4 writeMask[8];
- struct MrtConfig
- {
- bool blendEnable;
- bool separateAlpha;
- BlendState::BlendConfig color, alpha;
- };
- MrtConfig configs[8];
- Color4f constant;
- u32 customSampleMask;//0 is treated as 0xffffffff
- bool alphaToCoverage;
- PlatformBlendState platform;
- };
- struct VertexState
- {
- StreamFormatId format;
- BufferId streams[eiGX_MAX_VERTEX_STREAMS];
- u8 strides[eiGX_MAX_VERTEX_STREAMS];
- u32 offsets[eiGX_MAX_VERTEX_STREAMS];
- u32 numBuffers;
- BufferId indices;
- bool fatIndices;
- };
- struct InstanceState
- {
- u32 instanceCount; // How many instances to draw.
- BufferId streams[eiGX_MAX_VERTEX_STREAMS];
- u8 strides[eiGX_MAX_VERTEX_STREAMS];
- u32 offsets[eiGX_MAX_VERTEX_STREAMS];
- u32 numBuffers;
- };
- struct StreamOutState
- {
- BufferId streams[4];
- u32 numBuffers;
- };
- struct RasterState
- {
- CullMode::Type cullMode;
- FillMode::Type fillMode;
- float depthBias, slopeScale, depthBiasClamp;
- // The interpretation of the depth-bias values depends on the depth target format.
- // For integer depth buffers (these don't exist on PS4/Xbone!):
- // Bias = slopeScale * max(|dzdx|,|dzdy|) + depthBias * 1/2^bits_in_z_format
- // For floating point depth buffers:
- // Bias = slopeScale * max(|dzdx|,|dzdy|) + depthBias * 2^(exponent(max z in primitive) - mantissa_bits_in_z_format)
- // If depthBiasClamp is >0, FinalBias = min(Bias, depthBiasClamp)
- // If depthBiasClamp is <0, FinalBias = max(Bias, depthBiasClamp)
- };
- struct SamplerState
- {
- Filter::Type minFilter, magFilter, mipFilter;
- AddressMode::Type addressU, addressV, addressW;
- u8 maxAnisotropy;
- u8 minLod;
- u8 maxLod;
- float mipLodBias;
- Color4f border;
- ComparisonFunc::Type depthCompare;
- };
- class StateGroupWriter : NonCopyable
- {
- public:
- StateGroupWriter();
- ~StateGroupWriter();
- static StateGroup* CreateMerged( GpuDevice& gpu, Scope&, u32 count, const StateGroup*const* );
- static StateGroup* CreateMerged( GpuDevice& gpu, Persistent_tag, u32 count, const StateGroup*const* );
- // Either pass a Scope allocator, or pass 'Persistent'.
- // In the Persistent case: the resulting StateGroup must have it's Release function called.
- // In the Scope case: the StateGroup will be released automatically by the supplied Scope. Do not call Release on it.
- void Begin( GpuDevice&, Scope& );
- void Begin( GpuDevice&, Persistent_tag );
- StateGroup* End();
- //Shader program
- void SetShader( ShaderTechniqueId technique );
- void SetShaderOptions( u32 userFlags, u32 mask );
- //Render states
- void SetBlend( const BlendState& );
- void SetBlend( const MrtBlendState& );
- void SetDepthStencil( const DepthStencilState& );
- void SetRaster( const RasterState& );
- void SetScissor( const ScissorRect& );
- // Resource bindings
- void SetVertices( const VertexState& );
- void SetInstances( const InstanceState& );
- void SetConstantBuffer( int slot, ConstantBufferId );
- void SetResourceList( int slot, TextureId ); //helper for case where a ResourceList only contains one TextureId
- void SetResourceList( int slot, ResourceListId );
- void SetSampler( int slot, const SamplerState& );
- void SetStreamOut( const StreamOutState& );
- void SetRwResourceList( int slot, TextureId ); //helper for case where a ResourceList only contains one TextureId
- void SetRwResourceList( int slot, ResourceListId );
- private:
- Scope* m_alloc;
- GpuDevice* m_gpu;
- u8 _state[StateGroupWriterState_Size];
- StateGroupWriterState& State() { return *(StateGroupWriterState*)_state; }
- };
Add Comment
Please, Sign In to add comment