diff options
Diffstat (limited to 'src/video_core/shader/shader.cpp')
| -rw-r--r-- | src/video_core/shader/shader.cpp | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/src/video_core/shader/shader.cpp b/src/video_core/shader/shader.cpp index f565e2c91..852c5a9a0 100644 --- a/src/video_core/shader/shader.cpp +++ b/src/video_core/shader/shader.cpp | |||
| @@ -46,10 +46,8 @@ OutputVertex OutputRegisters::ToVertex(const Regs::ShaderConfig& config) { | |||
| 46 | 46 | ||
| 47 | const auto& output_register_map = g_state.regs.vs_output_attributes[index]; | 47 | const auto& output_register_map = g_state.regs.vs_output_attributes[index]; |
| 48 | 48 | ||
| 49 | u32 semantics[4] = { | 49 | u32 semantics[4] = {output_register_map.map_x, output_register_map.map_y, |
| 50 | output_register_map.map_x, output_register_map.map_y, | 50 | output_register_map.map_z, output_register_map.map_w}; |
| 51 | output_register_map.map_z, output_register_map.map_w | ||
| 52 | }; | ||
| 53 | 51 | ||
| 54 | for (unsigned comp = 0; comp < 4; ++comp) { | 52 | for (unsigned comp = 0; comp < 4; ++comp) { |
| 55 | float24* out = ((float24*)&ret) + semantics[comp]; | 53 | float24* out = ((float24*)&ret) + semantics[comp]; |
| @@ -65,19 +63,20 @@ OutputVertex OutputRegisters::ToVertex(const Regs::ShaderConfig& config) { | |||
| 65 | index++; | 63 | index++; |
| 66 | } | 64 | } |
| 67 | 65 | ||
| 68 | // The hardware takes the absolute and saturates vertex colors like this, *before* doing interpolation | 66 | // The hardware takes the absolute and saturates vertex colors like this, *before* doing |
| 67 | // interpolation | ||
| 69 | for (unsigned i = 0; i < 4; ++i) { | 68 | for (unsigned i = 0; i < 4; ++i) { |
| 70 | ret.color[i] = float24::FromFloat32( | 69 | ret.color[i] = float24::FromFloat32(std::fmin(std::fabs(ret.color[i].ToFloat32()), 1.0f)); |
| 71 | std::fmin(std::fabs(ret.color[i].ToFloat32()), 1.0f)); | ||
| 72 | } | 70 | } |
| 73 | 71 | ||
| 74 | LOG_TRACE(HW_GPU, "Output vertex: pos(%.2f, %.2f, %.2f, %.2f), quat(%.2f, %.2f, %.2f, %.2f), " | 72 | LOG_TRACE(HW_GPU, "Output vertex: pos(%.2f, %.2f, %.2f, %.2f), quat(%.2f, %.2f, %.2f, %.2f), " |
| 75 | "col(%.2f, %.2f, %.2f, %.2f), tc0(%.2f, %.2f), view(%.2f, %.2f, %.2f)", | 73 | "col(%.2f, %.2f, %.2f, %.2f), tc0(%.2f, %.2f), view(%.2f, %.2f, %.2f)", |
| 76 | ret.pos.x.ToFloat32(), ret.pos.y.ToFloat32(), ret.pos.z.ToFloat32(), ret.pos.w.ToFloat32(), | 74 | ret.pos.x.ToFloat32(), ret.pos.y.ToFloat32(), ret.pos.z.ToFloat32(), |
| 77 | ret.quat.x.ToFloat32(), ret.quat.y.ToFloat32(), ret.quat.z.ToFloat32(), ret.quat.w.ToFloat32(), | 75 | ret.pos.w.ToFloat32(), ret.quat.x.ToFloat32(), ret.quat.y.ToFloat32(), |
| 78 | ret.color.x.ToFloat32(), ret.color.y.ToFloat32(), ret.color.z.ToFloat32(), ret.color.w.ToFloat32(), | 76 | ret.quat.z.ToFloat32(), ret.quat.w.ToFloat32(), ret.color.x.ToFloat32(), |
| 79 | ret.tc0.u().ToFloat32(), ret.tc0.v().ToFloat32(), | 77 | ret.color.y.ToFloat32(), ret.color.z.ToFloat32(), ret.color.w.ToFloat32(), |
| 80 | ret.view.x.ToFloat32(), ret.view.y.ToFloat32(), ret.view.z.ToFloat32()); | 78 | ret.tc0.u().ToFloat32(), ret.tc0.v().ToFloat32(), ret.view.x.ToFloat32(), |
| 79 | ret.view.y.ToFloat32(), ret.view.z.ToFloat32()); | ||
| 81 | 80 | ||
| 82 | return ret; | 81 | return ret; |
| 83 | } | 82 | } |
| @@ -96,8 +95,9 @@ void ClearCache() { | |||
| 96 | void ShaderSetup::Setup() { | 95 | void ShaderSetup::Setup() { |
| 97 | #ifdef ARCHITECTURE_x86_64 | 96 | #ifdef ARCHITECTURE_x86_64 |
| 98 | if (VideoCore::g_shader_jit_enabled) { | 97 | if (VideoCore::g_shader_jit_enabled) { |
| 99 | u64 cache_key = (Common::ComputeHash64(&g_state.vs.program_code, sizeof(g_state.vs.program_code)) ^ | 98 | u64 cache_key = |
| 100 | Common::ComputeHash64(&g_state.vs.swizzle_data, sizeof(g_state.vs.swizzle_data))); | 99 | (Common::ComputeHash64(&g_state.vs.program_code, sizeof(g_state.vs.program_code)) ^ |
| 100 | Common::ComputeHash64(&g_state.vs.swizzle_data, sizeof(g_state.vs.swizzle_data))); | ||
| 101 | 101 | ||
| 102 | auto iter = shader_map.find(cache_key); | 102 | auto iter = shader_map.find(cache_key); |
| 103 | if (iter != shader_map.end()) { | 103 | if (iter != shader_map.end()) { |
| @@ -127,7 +127,7 @@ void ShaderSetup::Run(UnitState<false>& state, const InputVertex& input, int num | |||
| 127 | const auto& attribute_register_map = config.input_register_map; | 127 | const auto& attribute_register_map = config.input_register_map; |
| 128 | 128 | ||
| 129 | for (unsigned i = 0; i < num_attributes; i++) | 129 | for (unsigned i = 0; i < num_attributes; i++) |
| 130 | state.registers.input[attribute_register_map.GetRegisterForAttribute(i)] = input.attr[i]; | 130 | state.registers.input[attribute_register_map.GetRegisterForAttribute(i)] = input.attr[i]; |
| 131 | 131 | ||
| 132 | state.conditional_code[0] = false; | 132 | state.conditional_code[0] = false; |
| 133 | state.conditional_code[1] = false; | 133 | state.conditional_code[1] = false; |
| @@ -140,10 +140,11 @@ void ShaderSetup::Run(UnitState<false>& state, const InputVertex& input, int num | |||
| 140 | #else | 140 | #else |
| 141 | RunInterpreter(setup, state, config.main_offset); | 141 | RunInterpreter(setup, state, config.main_offset); |
| 142 | #endif // ARCHITECTURE_x86_64 | 142 | #endif // ARCHITECTURE_x86_64 |
| 143 | |||
| 144 | } | 143 | } |
| 145 | 144 | ||
| 146 | DebugData<true> ShaderSetup::ProduceDebugInfo(const InputVertex& input, int num_attributes, const Regs::ShaderConfig& config, const ShaderSetup& setup) { | 145 | DebugData<true> ShaderSetup::ProduceDebugInfo(const InputVertex& input, int num_attributes, |
| 146 | const Regs::ShaderConfig& config, | ||
| 147 | const ShaderSetup& setup) { | ||
| 147 | UnitState<true> state; | 148 | UnitState<true> state; |
| 148 | 149 | ||
| 149 | state.debug.max_offset = 0; | 150 | state.debug.max_offset = 0; |
| @@ -155,7 +156,7 @@ DebugData<true> ShaderSetup::ProduceDebugInfo(const InputVertex& input, int num_ | |||
| 155 | boost::fill(state.registers.input, &dummy_register); | 156 | boost::fill(state.registers.input, &dummy_register); |
| 156 | 157 | ||
| 157 | for (unsigned i = 0; i < num_attributes; i++) | 158 | for (unsigned i = 0; i < num_attributes; i++) |
| 158 | state.registers.input[attribute_register_map.GetRegisterForAttribute(i)] = input.attr[i]; | 159 | state.registers.input[attribute_register_map.GetRegisterForAttribute(i)] = input.attr[i]; |
| 159 | 160 | ||
| 160 | state.conditional_code[0] = false; | 161 | state.conditional_code[0] = false; |
| 161 | state.conditional_code[1] = false; | 162 | state.conditional_code[1] = false; |