/// <summary> /// Reloads the glsl shader file from the shader cache or saves a translated one if does not exist. /// </summary> public void ReloadGLSLShaderFile(BfshaLibrary.ResShaderProgram program) { if (IsSwitch) { DecodeSwitchBinary(program); } else { DecodeWiiUBinary(program); } UpdateShader = false; var matBlock = ShaderModel.UniformBlocks.Values.FirstOrDefault(x => x.Type == BfshaLibrary.UniformBlock.BlockType.Material); if (matBlock != null && GLShaderInfo != null) { var locationInfo = ProgramPasses[this.ShaderIndex].UniformBlockLocations[matBlock.Index]; string blockNameFSH = IsSwitch ? $"fp_c{locationInfo.FragmentLocation + 3}_data" : $"CBUFFER_{locationInfo.FragmentLocation}.values"; string blockNameVSH = IsSwitch ? $"vp_c{locationInfo.VertexLocation + 3}_data" : $"CBUFFER_{locationInfo.VertexLocation}.values"; GLShaderInfo.CreateUsedUniformListVertex(matBlock, blockNameVSH); GLShaderInfo.CreateUsedUniformListPixel(matBlock, blockNameFSH); } }
private void DecodeWiiUBinary(BfshaLibrary.ResShaderProgram program) { var vertexShader = BfshaGX2ShaderHelper.CreateVertexShader(ShaderModel, program); var pixelShader = BfshaGX2ShaderHelper.CreatePixelShader(ShaderModel, program); GLShaders[ShaderIndex] = CafeShaderDecoder.LoadShaderProgram(vertexShader, pixelShader); shaderProgram = GLShaderInfo.Program; }
private void DecodeSwitchBinary(BfshaLibrary.ResShaderProgram program) { GLShaders[ShaderIndex] = TegraShaderDecoder.LoadShaderProgram(ShaderModel, ShaderModel.GetShaderVariation(program)); shaderProgram = GLShaderInfo.Program; }