protected void ValidateInit(ref RenderStateDesc desc)
        {
            int constantBufferCount = desc.constantBuffers != null ? desc.constantBuffers.Length : 0;

            if (desc.shaderEffect.constantBufferCount != constantBufferCount)
            {
                throw new ArgumentException("RenderState constant-buffer count doesn't match ShaderEffect requirements");
            }

            int textureCount = desc.textures != null ? desc.textures.Length : 0;

            if (desc.shaderEffect.textureCount != textureCount)
            {
                throw new ArgumentException("RenderState texture count doesn't match ShaderEffect requirements");
            }
        }
예제 #2
0
 public abstract RenderStateBase CreateRenderState(RenderStateDesc desc);
예제 #3
0
        protected void InitBase(ref RenderStateDesc desc)
        {
            int constantBufferCount = desc.constantBuffers != null ? desc.constantBuffers.Length : 0;

            if (desc.shaderEffect.constantBufferCount != constantBufferCount)
            {
                throw new ArgumentException("RenderStateDesc constant-buffer count doesn't match ShaderEffect requirements");
            }

            int textureCount = desc.textures != null ? desc.textures.Length : 0;

            if (desc.shaderEffect.textureCount != textureCount)
            {
                throw new ArgumentException("RenderStateDesc texture count doesn't match ShaderEffect requirements");
            }

            int randomAccessBufferCount = desc.randomAccessBuffers != null ? desc.randomAccessBuffers.Length : 0;

            if (desc.shaderEffect.randomAccessBufferCount != randomAccessBufferCount)
            {
                throw new ArgumentException("RenderStateDesc random access buffer count doesn't match ShaderEffect requirements");
            }

            // validate independentBlendEnable is true settings
            if (desc.blendDesc.independentBlendEnable)
            {
                // validate render-target blend descriptions length matches render-pass render-target count
                if (desc.blendDesc.renderTargetBlendDescs == null || desc.blendDesc.renderTargetBlendDescs.Length != desc.renderPass.renderTargetCount)
                {
                    throw new ArgumentException("'independentBlendEnable' requires 'renderTargetBlendDescs' length to match RenderPass render-target count");
                }

                // validate 'logicOperationEnabled' is not enabled when 'independentBlendEnable' is
                if (desc.blendDesc.renderTargetBlendDescs != null)
                {
                    foreach (var blendDesc in desc.blendDesc.renderTargetBlendDescs)
                    {
                        if (blendDesc.logicOperationEnabled)
                        {
                            throw new ArgumentException("'logicOperationEnabled' cannot be enabled when 'independentBlendEnable' is enabled");
                        }
                    }
                }
            }

            // validate 'renderTargetBlendDescs' is null or length = 1 when 'independentBlendEnable' is disabled
            if (!desc.blendDesc.independentBlendEnable && desc.blendDesc.renderTargetBlendDescs != null && desc.blendDesc.renderTargetBlendDescs.Length != 1)
            {
                throw new ArgumentException("'independentBlendEnable' set to false requires 'renderTargetBlendDescs' length to equal 1");
            }

            // validate both 'blendingEnabled' and 'logicOperationEnabled' are not enabled at the same time
            if (desc.blendDesc.renderTargetBlendDescs != null)
            {
                foreach (var blendDesc in desc.blendDesc.renderTargetBlendDescs)
                {
                    if (blendDesc.blendingEnabled && blendDesc.logicOperationEnabled)
                    {
                        throw new ArgumentException("Only 'blendingEnabled' or 'logicOperationEnabled' can be enabled not both");
                    }
                }
            }

            // if index-buffer override is null, use built in vertex-buffer one
            if (desc.indexBuffer == null)
            {
                var vertexBuffer = desc.vertexBufferStreamer.vertexBuffers[0];
                desc.indexBuffer = vertexBuffer.indexBuffer;
            }
        }
예제 #4
0
 public abstract RenderStateBase CreateRenderState(RenderStateDesc desc, int gpuIndex);