Ejemplo n.º 1
0
        public override bool Equals(object obj)
        {
            H1Shader shader = obj as H1Shader;

            if (shader == null)
            {
                return(false);
            }

            if (this.m_Id != shader.m_Id) // comparing ids
            {
                return(false);
            }

            if (this.m_ShaderTypeRef != shader.m_ShaderTypeRef) // comparing shader type
            {
                return(false);
            }

            if (!(this.m_CompiledByteCode.SequenceEqual(shader.m_CompiledByteCode))) // comparing code bytes
            {
                return(false);
            }

            return(true);
        }
        public H1Shader CompileShader(String debugGroupName, H1VertexFactoryType vertexFactoryType, H1ShaderType shaderType, H1ShaderCompileHelper.H1ShaderCompileInput input)
        {
            // compile the shader
            H1ShaderCompileHelper.H1ShaderCompileOutput shaderCompileOutput = new H1ShaderCompileHelper.H1ShaderCompileOutput();
            H1ShaderCompileHelper.CompileD3D12Shader(input, shaderCompileOutput);

            if (!shaderCompileOutput.IsSucceed)
            {
                throw new Exception("failed to compile the shader! please check!");
            }

            H1Shader outShader = null;

            if (shaderType != null)
            {
                // create shader instance
                outShader = shaderType.FinishCompileShader(shaderCompileOutput);

                if (shaderType is H1GlobalShaderType) // only for global shader, add global shaders
                {
                    m_GlobalShaders.Add(outShader);
                }
                else // otherwise add local shaders
                {
                    m_LocalShaders.Add(outShader);
                }
            }

            return(outShader);
        }
Ejemplo n.º 3
0
        public H1Shader GetShader(String shaderTypeName, H1VertexFactoryType vertexFactoryType)
        {
            H1MeshMaterialShaderType shaderType = H1Global <H1ManagedRenderer> .Instance.ShaderManager.GetShaderType(shaderTypeName) as H1MeshMaterialShaderType;

            if (shaderType != null)
            {
                H1MeshMaterialShaderMap meshShaderMap = m_MaterialShaderMap.GetMeshShaderMap(vertexFactoryType);
                H1Shader shader = meshShaderMap != null ? meshShaderMap.Shaders[shaderType] : null;
                return(shader);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 4
0
        // note that - for this 'BeginCompile' call is called by H1MaterialMap usually!
        public void BeginCompile(uint shaderMapId, H1MaterialResource material, H1ShaderCompileHelper.H1ShaderCompilerEnvironment materialEnvironment)
        {
            // iterating shader type
            var shaderTypes = H1ShaderType.GetTypeList();

            foreach (var shaderType in shaderTypes)
            {
                H1MeshMaterialShaderType meshMaterialShaderType = shaderType.GetMeshMaterialShaderType();
                if (meshMaterialShaderType != null &&
                    m_VertexFactoryTypeRef != null &&
                    meshMaterialShaderType.ShouldCache(material, m_VertexFactoryTypeRef) &&
                    material.ShouldCache(meshMaterialShaderType, m_VertexFactoryTypeRef) &&
                    m_VertexFactoryTypeRef.ShouldCache(material, meshMaterialShaderType))
                {
                    // compile mesh material shader type (ex. vertex shader)
                    H1Shader shader = meshMaterialShaderType.BeginCompileShader(shaderMapId, material, materialEnvironment, m_VertexFactoryTypeRef);

                    // add shader to shader map
                    AddShader(meshMaterialShaderType, shader);
                }
            }
        }
Ejemplo n.º 5
0
 public void AddShader(H1ShaderType shaderType, H1Shader shader)
 {
     m_Shaders.Add(shaderType, shader);
 }