public ShaderModel(Shader shader, byte[] code, ShaderTypes shaderType) #endif : base(shader) { try { #if WINRT || WP8 this.shader = shader; #endif var video = shader.FindParentOrSelfWithException<Video>(); com = new ShaderModelCom(); #if WIN32 string shaderLvl = ""; switch (shaderVersion) { case ShaderVersions.HLSL_2_0: shaderLvl = "_4_0_level_9_1"; break; case ShaderVersions.HLSL_2_a: shaderLvl = "_4_0_level_9_2"; break; case ShaderVersions.HLSL_3_0: shaderLvl = "_4_0_level_9_3"; break; case ShaderVersions.HLSL_4_0: shaderLvl = "_4_0"; break; case ShaderVersions.HLSL_4_1: shaderLvl = "_4_1"; break; case ShaderVersions.HLSL_5_0: shaderLvl = "_5_0"; break; default: Debug.ThrowError("ShaderModel", "Unsuported ShaderVersion: " + shaderVersion); break; } string errorText; var error = com.Init(video.com, code, code.Length, shaderType.ToString().ToLower() + shaderLvl, out errorText); #else var error = com.Init ( video.com, code, code.Length, shaderType == ShaderTypes.VS ? shader.vsVariableBufferSize : shader.psVariableBufferSize, shaderType == ShaderTypes.VS ? shader.vsResourceCount : shader.psResourceCount ); #endif switch (error) { #if WIN32 case ShaderModelErrors.CompileCode: Debug.ThrowError("ShaderModel", "Shader compiler error: " + errorText); break; #endif case ShaderModelErrors.VariableBuffer: Debug.ThrowError("ShaderModel", "Failed to create VariableBuffer"); break; case ShaderModelErrors.Reflect: Debug.ThrowError("ShaderModel", "Failed to Reflect the shader"); break; } } catch (Exception e) { Dispose(); throw e; } }
public PixelShader(Shader shader, byte[] code) : base(shader, code, ShaderTypes.PS) #endif { try { var video = shader.FindParentOrSelfWithException<Video>(); pixelShaderCom = new PixelShaderCom(); var error = pixelShaderCom.Init(video.com, com); if (error == PixelShaderErrors.PixelShader) Debug.ThrowError("PixelShader", "Failed to create PixelShader"); } catch (Exception e) { Dispose(); throw e; } }
public ShaderModel(Shader shader, string code, ShaderTypes shaderType, ShaderVersions shaderVersion)
public PixelShader(Shader shader, string code, ShaderVersions shaderVersion) : base(shader, code, ShaderTypes.PS, shaderVersion)