diff options
| author | 2017-05-12 18:02:45 +0300 | |
|---|---|---|
| committer | 2017-05-12 18:02:45 +0300 | |
| commit | 9bd3986540a990abc82ef2b03fc4d621d78c2e03 (patch) | |
| tree | 7f10b237188546c98cc6ca54518cb63261216260 | |
| parent | Merge pull request #2669 from jroweboy/async_file_watcher (diff) | |
| parent | Pica: Write GS registers (diff) | |
| download | yuzu-9bd3986540a990abc82ef2b03fc4d621d78c2e03.tar.gz yuzu-9bd3986540a990abc82ef2b03fc4d621d78c2e03.tar.xz yuzu-9bd3986540a990abc82ef2b03fc4d621d78c2e03.zip | |
Merge pull request #2695 from JayFoxRox/gs-regs
Prepare Pica registers for Geometry Shaders
| -rw-r--r-- | src/video_core/command_processor.cpp | 212 | ||||
| -rw-r--r-- | src/video_core/shader/shader.h | 7 | ||||
| -rw-r--r-- | src/video_core/shader/shader_interpreter.cpp | 2 | ||||
| -rw-r--r-- | src/video_core/shader/shader_jit_x64.cpp | 2 | ||||
| -rw-r--r-- | src/video_core/shader/shader_jit_x64_compiler.cpp | 4 | ||||
| -rw-r--r-- | src/video_core/shader/shader_jit_x64_compiler.h | 14 |
6 files changed, 171 insertions, 70 deletions
diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp index 2e32ff905..9a09f81dc 100644 --- a/src/video_core/command_processor.cpp +++ b/src/video_core/command_processor.cpp | |||
| @@ -32,12 +32,13 @@ namespace Pica { | |||
| 32 | 32 | ||
| 33 | namespace CommandProcessor { | 33 | namespace CommandProcessor { |
| 34 | 34 | ||
| 35 | static int float_regs_counter = 0; | 35 | static int vs_float_regs_counter = 0; |
| 36 | static u32 vs_uniform_write_buffer[4]; | ||
| 36 | 37 | ||
| 37 | static u32 uniform_write_buffer[4]; | 38 | static int gs_float_regs_counter = 0; |
| 39 | static u32 gs_uniform_write_buffer[4]; | ||
| 38 | 40 | ||
| 39 | static int default_attr_counter = 0; | 41 | static int default_attr_counter = 0; |
| 40 | |||
| 41 | static u32 default_attr_write_buffer[3]; | 42 | static u32 default_attr_write_buffer[3]; |
| 42 | 43 | ||
| 43 | // Expand a 4-bit mask to 4-byte mask, e.g. 0b0101 -> 0x00FF00FF | 44 | // Expand a 4-bit mask to 4-byte mask, e.g. 0b0101 -> 0x00FF00FF |
| @@ -48,6 +49,97 @@ static const u32 expand_bits_to_bytes[] = { | |||
| 48 | 49 | ||
| 49 | MICROPROFILE_DEFINE(GPU_Drawing, "GPU", "Drawing", MP_RGB(50, 50, 240)); | 50 | MICROPROFILE_DEFINE(GPU_Drawing, "GPU", "Drawing", MP_RGB(50, 50, 240)); |
| 50 | 51 | ||
| 52 | static const char* GetShaderSetupTypeName(Shader::ShaderSetup& setup) { | ||
| 53 | if (&setup == &g_state.vs) { | ||
| 54 | return "vertex shader"; | ||
| 55 | } | ||
| 56 | if (&setup == &g_state.gs) { | ||
| 57 | return "geometry shader"; | ||
| 58 | } | ||
| 59 | return "unknown shader"; | ||
| 60 | } | ||
| 61 | |||
| 62 | static void WriteUniformBoolReg(Shader::ShaderSetup& setup, u32 value) { | ||
| 63 | for (unsigned i = 0; i < setup.uniforms.b.size(); ++i) | ||
| 64 | setup.uniforms.b[i] = (value & (1 << i)) != 0; | ||
| 65 | } | ||
| 66 | |||
| 67 | static void WriteUniformIntReg(Shader::ShaderSetup& setup, unsigned index, | ||
| 68 | const Math::Vec4<u8>& values) { | ||
| 69 | ASSERT(index < setup.uniforms.i.size()); | ||
| 70 | setup.uniforms.i[index] = values; | ||
| 71 | LOG_TRACE(HW_GPU, "Set %s integer uniform %d to %02x %02x %02x %02x", | ||
| 72 | GetShaderSetupTypeName(setup), index, values.x, values.y, values.z, values.w); | ||
| 73 | } | ||
| 74 | |||
| 75 | static void WriteUniformFloatReg(ShaderRegs& config, Shader::ShaderSetup& setup, | ||
| 76 | int& float_regs_counter, u32 uniform_write_buffer[4], u32 value) { | ||
| 77 | auto& uniform_setup = config.uniform_setup; | ||
| 78 | |||
| 79 | // TODO: Does actual hardware indeed keep an intermediate buffer or does | ||
| 80 | // it directly write the values? | ||
| 81 | uniform_write_buffer[float_regs_counter++] = value; | ||
| 82 | |||
| 83 | // Uniforms are written in a packed format such that four float24 values are encoded in | ||
| 84 | // three 32-bit numbers. We write to internal memory once a full such vector is | ||
| 85 | // written. | ||
| 86 | if ((float_regs_counter >= 4 && uniform_setup.IsFloat32()) || | ||
| 87 | (float_regs_counter >= 3 && !uniform_setup.IsFloat32())) { | ||
| 88 | float_regs_counter = 0; | ||
| 89 | |||
| 90 | auto& uniform = setup.uniforms.f[uniform_setup.index]; | ||
| 91 | |||
| 92 | if (uniform_setup.index >= 96) { | ||
| 93 | LOG_ERROR(HW_GPU, "Invalid %s float uniform index %d", GetShaderSetupTypeName(setup), | ||
| 94 | (int)uniform_setup.index); | ||
| 95 | } else { | ||
| 96 | |||
| 97 | // NOTE: The destination component order indeed is "backwards" | ||
| 98 | if (uniform_setup.IsFloat32()) { | ||
| 99 | for (auto i : {0, 1, 2, 3}) | ||
| 100 | uniform[3 - i] = float24::FromFloat32(*(float*)(&uniform_write_buffer[i])); | ||
| 101 | } else { | ||
| 102 | // TODO: Untested | ||
| 103 | uniform.w = float24::FromRaw(uniform_write_buffer[0] >> 8); | ||
| 104 | uniform.z = float24::FromRaw(((uniform_write_buffer[0] & 0xFF) << 16) | | ||
| 105 | ((uniform_write_buffer[1] >> 16) & 0xFFFF)); | ||
| 106 | uniform.y = float24::FromRaw(((uniform_write_buffer[1] & 0xFFFF) << 8) | | ||
| 107 | ((uniform_write_buffer[2] >> 24) & 0xFF)); | ||
| 108 | uniform.x = float24::FromRaw(uniform_write_buffer[2] & 0xFFFFFF); | ||
| 109 | } | ||
| 110 | |||
| 111 | LOG_TRACE(HW_GPU, "Set %s float uniform %x to (%f %f %f %f)", | ||
| 112 | GetShaderSetupTypeName(setup), (int)uniform_setup.index, | ||
| 113 | uniform.x.ToFloat32(), uniform.y.ToFloat32(), uniform.z.ToFloat32(), | ||
| 114 | uniform.w.ToFloat32()); | ||
| 115 | |||
| 116 | // TODO: Verify that this actually modifies the register! | ||
| 117 | uniform_setup.index.Assign(uniform_setup.index + 1); | ||
| 118 | } | ||
| 119 | } | ||
| 120 | } | ||
| 121 | |||
| 122 | static void WriteProgramCode(ShaderRegs& config, Shader::ShaderSetup& setup, | ||
| 123 | unsigned max_program_code_length, u32 value) { | ||
| 124 | if (config.program.offset >= max_program_code_length) { | ||
| 125 | LOG_ERROR(HW_GPU, "Invalid %s program offset %d", GetShaderSetupTypeName(setup), | ||
| 126 | (int)config.program.offset); | ||
| 127 | } else { | ||
| 128 | setup.program_code[config.program.offset] = value; | ||
| 129 | config.program.offset++; | ||
| 130 | } | ||
| 131 | } | ||
| 132 | |||
| 133 | static void WriteSwizzlePatterns(ShaderRegs& config, Shader::ShaderSetup& setup, u32 value) { | ||
| 134 | if (config.swizzle_patterns.offset >= setup.swizzle_data.size()) { | ||
| 135 | LOG_ERROR(HW_GPU, "Invalid %s swizzle pattern offset %d", GetShaderSetupTypeName(setup), | ||
| 136 | (int)config.swizzle_patterns.offset); | ||
| 137 | } else { | ||
| 138 | setup.swizzle_data[config.swizzle_patterns.offset] = value; | ||
| 139 | config.swizzle_patterns.offset++; | ||
| 140 | } | ||
| 141 | } | ||
| 142 | |||
| 51 | static void WritePicaReg(u32 id, u32 value, u32 mask) { | 143 | static void WritePicaReg(u32 id, u32 value, u32 mask) { |
| 52 | auto& regs = g_state.regs; | 144 | auto& regs = g_state.regs; |
| 53 | 145 | ||
| @@ -330,21 +422,70 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) { | |||
| 330 | break; | 422 | break; |
| 331 | } | 423 | } |
| 332 | 424 | ||
| 333 | case PICA_REG_INDEX(vs.bool_uniforms): | 425 | case PICA_REG_INDEX(gs.bool_uniforms): |
| 334 | for (unsigned i = 0; i < 16; ++i) | 426 | WriteUniformBoolReg(g_state.gs, value); |
| 335 | g_state.vs.uniforms.b[i] = (regs.vs.bool_uniforms.Value() & (1 << i)) != 0; | 427 | break; |
| 336 | 428 | ||
| 429 | case PICA_REG_INDEX_WORKAROUND(gs.int_uniforms[0], 0x281): | ||
| 430 | case PICA_REG_INDEX_WORKAROUND(gs.int_uniforms[1], 0x282): | ||
| 431 | case PICA_REG_INDEX_WORKAROUND(gs.int_uniforms[2], 0x283): | ||
| 432 | case PICA_REG_INDEX_WORKAROUND(gs.int_uniforms[3], 0x284): { | ||
| 433 | unsigned index = (id - PICA_REG_INDEX_WORKAROUND(gs.int_uniforms[0], 0x281)); | ||
| 434 | auto values = regs.gs.int_uniforms[index]; | ||
| 435 | WriteUniformIntReg(g_state.gs, index, | ||
| 436 | Math::Vec4<u8>(values.x, values.y, values.z, values.w)); | ||
| 437 | break; | ||
| 438 | } | ||
| 439 | |||
| 440 | case PICA_REG_INDEX_WORKAROUND(gs.uniform_setup.set_value[0], 0x291): | ||
| 441 | case PICA_REG_INDEX_WORKAROUND(gs.uniform_setup.set_value[1], 0x292): | ||
| 442 | case PICA_REG_INDEX_WORKAROUND(gs.uniform_setup.set_value[2], 0x293): | ||
| 443 | case PICA_REG_INDEX_WORKAROUND(gs.uniform_setup.set_value[3], 0x294): | ||
| 444 | case PICA_REG_INDEX_WORKAROUND(gs.uniform_setup.set_value[4], 0x295): | ||
| 445 | case PICA_REG_INDEX_WORKAROUND(gs.uniform_setup.set_value[5], 0x296): | ||
| 446 | case PICA_REG_INDEX_WORKAROUND(gs.uniform_setup.set_value[6], 0x297): | ||
| 447 | case PICA_REG_INDEX_WORKAROUND(gs.uniform_setup.set_value[7], 0x298): { | ||
| 448 | WriteUniformFloatReg(g_state.regs.gs, g_state.gs, gs_float_regs_counter, | ||
| 449 | gs_uniform_write_buffer, value); | ||
| 450 | break; | ||
| 451 | } | ||
| 452 | |||
| 453 | case PICA_REG_INDEX_WORKAROUND(gs.program.set_word[0], 0x29c): | ||
| 454 | case PICA_REG_INDEX_WORKAROUND(gs.program.set_word[1], 0x29d): | ||
| 455 | case PICA_REG_INDEX_WORKAROUND(gs.program.set_word[2], 0x29e): | ||
| 456 | case PICA_REG_INDEX_WORKAROUND(gs.program.set_word[3], 0x29f): | ||
| 457 | case PICA_REG_INDEX_WORKAROUND(gs.program.set_word[4], 0x2a0): | ||
| 458 | case PICA_REG_INDEX_WORKAROUND(gs.program.set_word[5], 0x2a1): | ||
| 459 | case PICA_REG_INDEX_WORKAROUND(gs.program.set_word[6], 0x2a2): | ||
| 460 | case PICA_REG_INDEX_WORKAROUND(gs.program.set_word[7], 0x2a3): { | ||
| 461 | WriteProgramCode(g_state.regs.gs, g_state.gs, 4096, value); | ||
| 462 | break; | ||
| 463 | } | ||
| 464 | |||
| 465 | case PICA_REG_INDEX_WORKAROUND(gs.swizzle_patterns.set_word[0], 0x2a6): | ||
| 466 | case PICA_REG_INDEX_WORKAROUND(gs.swizzle_patterns.set_word[1], 0x2a7): | ||
| 467 | case PICA_REG_INDEX_WORKAROUND(gs.swizzle_patterns.set_word[2], 0x2a8): | ||
| 468 | case PICA_REG_INDEX_WORKAROUND(gs.swizzle_patterns.set_word[3], 0x2a9): | ||
| 469 | case PICA_REG_INDEX_WORKAROUND(gs.swizzle_patterns.set_word[4], 0x2aa): | ||
| 470 | case PICA_REG_INDEX_WORKAROUND(gs.swizzle_patterns.set_word[5], 0x2ab): | ||
| 471 | case PICA_REG_INDEX_WORKAROUND(gs.swizzle_patterns.set_word[6], 0x2ac): | ||
| 472 | case PICA_REG_INDEX_WORKAROUND(gs.swizzle_patterns.set_word[7], 0x2ad): { | ||
| 473 | WriteSwizzlePatterns(g_state.regs.gs, g_state.gs, value); | ||
| 474 | break; | ||
| 475 | } | ||
| 476 | |||
| 477 | case PICA_REG_INDEX(vs.bool_uniforms): | ||
| 478 | WriteUniformBoolReg(g_state.vs, value); | ||
| 337 | break; | 479 | break; |
| 338 | 480 | ||
| 339 | case PICA_REG_INDEX_WORKAROUND(vs.int_uniforms[0], 0x2b1): | 481 | case PICA_REG_INDEX_WORKAROUND(vs.int_uniforms[0], 0x2b1): |
| 340 | case PICA_REG_INDEX_WORKAROUND(vs.int_uniforms[1], 0x2b2): | 482 | case PICA_REG_INDEX_WORKAROUND(vs.int_uniforms[1], 0x2b2): |
| 341 | case PICA_REG_INDEX_WORKAROUND(vs.int_uniforms[2], 0x2b3): | 483 | case PICA_REG_INDEX_WORKAROUND(vs.int_uniforms[2], 0x2b3): |
| 342 | case PICA_REG_INDEX_WORKAROUND(vs.int_uniforms[3], 0x2b4): { | 484 | case PICA_REG_INDEX_WORKAROUND(vs.int_uniforms[3], 0x2b4): { |
| 343 | int index = (id - PICA_REG_INDEX_WORKAROUND(vs.int_uniforms[0], 0x2b1)); | 485 | unsigned index = (id - PICA_REG_INDEX_WORKAROUND(vs.int_uniforms[0], 0x2b1)); |
| 344 | auto values = regs.vs.int_uniforms[index]; | 486 | auto values = regs.vs.int_uniforms[index]; |
| 345 | g_state.vs.uniforms.i[index] = Math::Vec4<u8>(values.x, values.y, values.z, values.w); | 487 | WriteUniformIntReg(g_state.vs, index, |
| 346 | LOG_TRACE(HW_GPU, "Set integer uniform %d to %02x %02x %02x %02x", index, values.x.Value(), | 488 | Math::Vec4<u8>(values.x, values.y, values.z, values.w)); |
| 347 | values.y.Value(), values.z.Value(), values.w.Value()); | ||
| 348 | break; | 489 | break; |
| 349 | } | 490 | } |
| 350 | 491 | ||
| @@ -356,51 +497,11 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) { | |||
| 356 | case PICA_REG_INDEX_WORKAROUND(vs.uniform_setup.set_value[5], 0x2c6): | 497 | case PICA_REG_INDEX_WORKAROUND(vs.uniform_setup.set_value[5], 0x2c6): |
| 357 | case PICA_REG_INDEX_WORKAROUND(vs.uniform_setup.set_value[6], 0x2c7): | 498 | case PICA_REG_INDEX_WORKAROUND(vs.uniform_setup.set_value[6], 0x2c7): |
| 358 | case PICA_REG_INDEX_WORKAROUND(vs.uniform_setup.set_value[7], 0x2c8): { | 499 | case PICA_REG_INDEX_WORKAROUND(vs.uniform_setup.set_value[7], 0x2c8): { |
| 359 | auto& uniform_setup = regs.vs.uniform_setup; | 500 | WriteUniformFloatReg(g_state.regs.vs, g_state.vs, vs_float_regs_counter, |
| 360 | 501 | vs_uniform_write_buffer, value); | |
| 361 | // TODO: Does actual hardware indeed keep an intermediate buffer or does | ||
| 362 | // it directly write the values? | ||
| 363 | uniform_write_buffer[float_regs_counter++] = value; | ||
| 364 | |||
| 365 | // Uniforms are written in a packed format such that four float24 values are encoded in | ||
| 366 | // three 32-bit numbers. We write to internal memory once a full such vector is | ||
| 367 | // written. | ||
| 368 | if ((float_regs_counter >= 4 && uniform_setup.IsFloat32()) || | ||
| 369 | (float_regs_counter >= 3 && !uniform_setup.IsFloat32())) { | ||
| 370 | float_regs_counter = 0; | ||
| 371 | |||
| 372 | auto& uniform = g_state.vs.uniforms.f[uniform_setup.index]; | ||
| 373 | |||
| 374 | if (uniform_setup.index > 95) { | ||
| 375 | LOG_ERROR(HW_GPU, "Invalid VS uniform index %d", (int)uniform_setup.index); | ||
| 376 | break; | ||
| 377 | } | ||
| 378 | |||
| 379 | // NOTE: The destination component order indeed is "backwards" | ||
| 380 | if (uniform_setup.IsFloat32()) { | ||
| 381 | for (auto i : {0, 1, 2, 3}) | ||
| 382 | uniform[3 - i] = float24::FromFloat32(*(float*)(&uniform_write_buffer[i])); | ||
| 383 | } else { | ||
| 384 | // TODO: Untested | ||
| 385 | uniform.w = float24::FromRaw(uniform_write_buffer[0] >> 8); | ||
| 386 | uniform.z = float24::FromRaw(((uniform_write_buffer[0] & 0xFF) << 16) | | ||
| 387 | ((uniform_write_buffer[1] >> 16) & 0xFFFF)); | ||
| 388 | uniform.y = float24::FromRaw(((uniform_write_buffer[1] & 0xFFFF) << 8) | | ||
| 389 | ((uniform_write_buffer[2] >> 24) & 0xFF)); | ||
| 390 | uniform.x = float24::FromRaw(uniform_write_buffer[2] & 0xFFFFFF); | ||
| 391 | } | ||
| 392 | |||
| 393 | LOG_TRACE(HW_GPU, "Set uniform %x to (%f %f %f %f)", (int)uniform_setup.index, | ||
| 394 | uniform.x.ToFloat32(), uniform.y.ToFloat32(), uniform.z.ToFloat32(), | ||
| 395 | uniform.w.ToFloat32()); | ||
| 396 | |||
| 397 | // TODO: Verify that this actually modifies the register! | ||
| 398 | uniform_setup.index.Assign(uniform_setup.index + 1); | ||
| 399 | } | ||
| 400 | break; | 502 | break; |
| 401 | } | 503 | } |
| 402 | 504 | ||
| 403 | // Load shader program code | ||
| 404 | case PICA_REG_INDEX_WORKAROUND(vs.program.set_word[0], 0x2cc): | 505 | case PICA_REG_INDEX_WORKAROUND(vs.program.set_word[0], 0x2cc): |
| 405 | case PICA_REG_INDEX_WORKAROUND(vs.program.set_word[1], 0x2cd): | 506 | case PICA_REG_INDEX_WORKAROUND(vs.program.set_word[1], 0x2cd): |
| 406 | case PICA_REG_INDEX_WORKAROUND(vs.program.set_word[2], 0x2ce): | 507 | case PICA_REG_INDEX_WORKAROUND(vs.program.set_word[2], 0x2ce): |
| @@ -409,12 +510,10 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) { | |||
| 409 | case PICA_REG_INDEX_WORKAROUND(vs.program.set_word[5], 0x2d1): | 510 | case PICA_REG_INDEX_WORKAROUND(vs.program.set_word[5], 0x2d1): |
| 410 | case PICA_REG_INDEX_WORKAROUND(vs.program.set_word[6], 0x2d2): | 511 | case PICA_REG_INDEX_WORKAROUND(vs.program.set_word[6], 0x2d2): |
| 411 | case PICA_REG_INDEX_WORKAROUND(vs.program.set_word[7], 0x2d3): { | 512 | case PICA_REG_INDEX_WORKAROUND(vs.program.set_word[7], 0x2d3): { |
| 412 | g_state.vs.program_code[regs.vs.program.offset] = value; | 513 | WriteProgramCode(g_state.regs.vs, g_state.vs, 512, value); |
| 413 | regs.vs.program.offset++; | ||
| 414 | break; | 514 | break; |
| 415 | } | 515 | } |
| 416 | 516 | ||
| 417 | // Load swizzle pattern data | ||
| 418 | case PICA_REG_INDEX_WORKAROUND(vs.swizzle_patterns.set_word[0], 0x2d6): | 517 | case PICA_REG_INDEX_WORKAROUND(vs.swizzle_patterns.set_word[0], 0x2d6): |
| 419 | case PICA_REG_INDEX_WORKAROUND(vs.swizzle_patterns.set_word[1], 0x2d7): | 518 | case PICA_REG_INDEX_WORKAROUND(vs.swizzle_patterns.set_word[1], 0x2d7): |
| 420 | case PICA_REG_INDEX_WORKAROUND(vs.swizzle_patterns.set_word[2], 0x2d8): | 519 | case PICA_REG_INDEX_WORKAROUND(vs.swizzle_patterns.set_word[2], 0x2d8): |
| @@ -423,8 +522,7 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) { | |||
| 423 | case PICA_REG_INDEX_WORKAROUND(vs.swizzle_patterns.set_word[5], 0x2db): | 522 | case PICA_REG_INDEX_WORKAROUND(vs.swizzle_patterns.set_word[5], 0x2db): |
| 424 | case PICA_REG_INDEX_WORKAROUND(vs.swizzle_patterns.set_word[6], 0x2dc): | 523 | case PICA_REG_INDEX_WORKAROUND(vs.swizzle_patterns.set_word[6], 0x2dc): |
| 425 | case PICA_REG_INDEX_WORKAROUND(vs.swizzle_patterns.set_word[7], 0x2dd): { | 524 | case PICA_REG_INDEX_WORKAROUND(vs.swizzle_patterns.set_word[7], 0x2dd): { |
| 426 | g_state.vs.swizzle_data[regs.vs.swizzle_patterns.offset] = value; | 525 | WriteSwizzlePatterns(g_state.regs.vs, g_state.vs, value); |
| 427 | regs.vs.swizzle_patterns.offset++; | ||
| 428 | break; | 526 | break; |
| 429 | } | 527 | } |
| 430 | 528 | ||
diff --git a/src/video_core/shader/shader.h b/src/video_core/shader/shader.h index 38ea717ab..e156f6aef 100644 --- a/src/video_core/shader/shader.h +++ b/src/video_core/shader/shader.h | |||
| @@ -24,6 +24,9 @@ namespace Pica { | |||
| 24 | 24 | ||
| 25 | namespace Shader { | 25 | namespace Shader { |
| 26 | 26 | ||
| 27 | constexpr unsigned MAX_PROGRAM_CODE_LENGTH = 4096; | ||
| 28 | constexpr unsigned MAX_SWIZZLE_DATA_LENGTH = 4096; | ||
| 29 | |||
| 27 | struct AttributeBuffer { | 30 | struct AttributeBuffer { |
| 28 | alignas(16) Math::Vec4<float24> attr[16]; | 31 | alignas(16) Math::Vec4<float24> attr[16]; |
| 29 | }; | 32 | }; |
| @@ -144,8 +147,8 @@ struct ShaderSetup { | |||
| 144 | return offsetof(ShaderSetup, uniforms.i) + index * sizeof(Math::Vec4<u8>); | 147 | return offsetof(ShaderSetup, uniforms.i) + index * sizeof(Math::Vec4<u8>); |
| 145 | } | 148 | } |
| 146 | 149 | ||
| 147 | std::array<u32, 1024> program_code; | 150 | std::array<u32, MAX_PROGRAM_CODE_LENGTH> program_code; |
| 148 | std::array<u32, 1024> swizzle_data; | 151 | std::array<u32, MAX_SWIZZLE_DATA_LENGTH> swizzle_data; |
| 149 | 152 | ||
| 150 | /// Data private to ShaderEngines | 153 | /// Data private to ShaderEngines |
| 151 | struct EngineData { | 154 | struct EngineData { |
diff --git a/src/video_core/shader/shader_interpreter.cpp b/src/video_core/shader/shader_interpreter.cpp index f4d1c46c5..aa1cec81f 100644 --- a/src/video_core/shader/shader_interpreter.cpp +++ b/src/video_core/shader/shader_interpreter.cpp | |||
| @@ -653,7 +653,7 @@ static void RunInterpreter(const ShaderSetup& setup, UnitState& state, DebugData | |||
| 653 | } | 653 | } |
| 654 | 654 | ||
| 655 | void InterpreterEngine::SetupBatch(ShaderSetup& setup, unsigned int entry_point) { | 655 | void InterpreterEngine::SetupBatch(ShaderSetup& setup, unsigned int entry_point) { |
| 656 | ASSERT(entry_point < 1024); | 656 | ASSERT(entry_point < MAX_PROGRAM_CODE_LENGTH); |
| 657 | setup.engine_data.entry_point = entry_point; | 657 | setup.engine_data.entry_point = entry_point; |
| 658 | } | 658 | } |
| 659 | 659 | ||
diff --git a/src/video_core/shader/shader_jit_x64.cpp b/src/video_core/shader/shader_jit_x64.cpp index 0ee0dd9ef..73c21871c 100644 --- a/src/video_core/shader/shader_jit_x64.cpp +++ b/src/video_core/shader/shader_jit_x64.cpp | |||
| @@ -15,7 +15,7 @@ JitX64Engine::JitX64Engine() = default; | |||
| 15 | JitX64Engine::~JitX64Engine() = default; | 15 | JitX64Engine::~JitX64Engine() = default; |
| 16 | 16 | ||
| 17 | void JitX64Engine::SetupBatch(ShaderSetup& setup, unsigned int entry_point) { | 17 | void JitX64Engine::SetupBatch(ShaderSetup& setup, unsigned int entry_point) { |
| 18 | ASSERT(entry_point < 1024); | 18 | ASSERT(entry_point < MAX_PROGRAM_CODE_LENGTH); |
| 19 | setup.engine_data.entry_point = entry_point; | 19 | setup.engine_data.entry_point = entry_point; |
| 20 | 20 | ||
| 21 | u64 code_hash = Common::ComputeHash64(&setup.program_code, sizeof(setup.program_code)); | 21 | u64 code_hash = Common::ComputeHash64(&setup.program_code, sizeof(setup.program_code)); |
diff --git a/src/video_core/shader/shader_jit_x64_compiler.cpp b/src/video_core/shader/shader_jit_x64_compiler.cpp index 2dbc8b147..5d9b6448c 100644 --- a/src/video_core/shader/shader_jit_x64_compiler.cpp +++ b/src/video_core/shader/shader_jit_x64_compiler.cpp | |||
| @@ -834,8 +834,8 @@ void JitShader::FindReturnOffsets() { | |||
| 834 | std::sort(return_offsets.begin(), return_offsets.end()); | 834 | std::sort(return_offsets.begin(), return_offsets.end()); |
| 835 | } | 835 | } |
| 836 | 836 | ||
| 837 | void JitShader::Compile(const std::array<u32, 1024>* program_code_, | 837 | void JitShader::Compile(const std::array<u32, MAX_PROGRAM_CODE_LENGTH>* program_code_, |
| 838 | const std::array<u32, 1024>* swizzle_data_) { | 838 | const std::array<u32, MAX_SWIZZLE_DATA_LENGTH>* swizzle_data_) { |
| 839 | program_code = program_code_; | 839 | program_code = program_code_; |
| 840 | swizzle_data = swizzle_data_; | 840 | swizzle_data = swizzle_data_; |
| 841 | 841 | ||
diff --git a/src/video_core/shader/shader_jit_x64_compiler.h b/src/video_core/shader/shader_jit_x64_compiler.h index f27675560..31af0ca48 100644 --- a/src/video_core/shader/shader_jit_x64_compiler.h +++ b/src/video_core/shader/shader_jit_x64_compiler.h | |||
| @@ -22,8 +22,8 @@ namespace Pica { | |||
| 22 | 22 | ||
| 23 | namespace Shader { | 23 | namespace Shader { |
| 24 | 24 | ||
| 25 | /// Memory allocated for each compiled shader (64Kb) | 25 | /// Memory allocated for each compiled shader |
| 26 | constexpr size_t MAX_SHADER_SIZE = 1024 * 64; | 26 | constexpr size_t MAX_SHADER_SIZE = MAX_PROGRAM_CODE_LENGTH * 64; |
| 27 | 27 | ||
| 28 | /** | 28 | /** |
| 29 | * This class implements the shader JIT compiler. It recompiles a Pica shader program into x86_64 | 29 | * This class implements the shader JIT compiler. It recompiles a Pica shader program into x86_64 |
| @@ -37,8 +37,8 @@ public: | |||
| 37 | program(&setup, &state, instruction_labels[offset].getAddress()); | 37 | program(&setup, &state, instruction_labels[offset].getAddress()); |
| 38 | } | 38 | } |
| 39 | 39 | ||
| 40 | void Compile(const std::array<u32, 1024>* program_code, | 40 | void Compile(const std::array<u32, MAX_PROGRAM_CODE_LENGTH>* program_code, |
| 41 | const std::array<u32, 1024>* swizzle_data); | 41 | const std::array<u32, MAX_SWIZZLE_DATA_LENGTH>* swizzle_data); |
| 42 | 42 | ||
| 43 | void Compile_ADD(Instruction instr); | 43 | void Compile_ADD(Instruction instr); |
| 44 | void Compile_DP3(Instruction instr); | 44 | void Compile_DP3(Instruction instr); |
| @@ -104,11 +104,11 @@ private: | |||
| 104 | */ | 104 | */ |
| 105 | void FindReturnOffsets(); | 105 | void FindReturnOffsets(); |
| 106 | 106 | ||
| 107 | const std::array<u32, 1024>* program_code = nullptr; | 107 | const std::array<u32, MAX_PROGRAM_CODE_LENGTH>* program_code = nullptr; |
| 108 | const std::array<u32, 1024>* swizzle_data = nullptr; | 108 | const std::array<u32, MAX_SWIZZLE_DATA_LENGTH>* swizzle_data = nullptr; |
| 109 | 109 | ||
| 110 | /// Mapping of Pica VS instructions to pointers in the emitted code | 110 | /// Mapping of Pica VS instructions to pointers in the emitted code |
| 111 | std::array<Xbyak::Label, 1024> instruction_labels; | 111 | std::array<Xbyak::Label, MAX_PROGRAM_CODE_LENGTH> instruction_labels; |
| 112 | 112 | ||
| 113 | /// Offsets in code where a return needs to be inserted | 113 | /// Offsets in code where a return needs to be inserted |
| 114 | std::vector<unsigned> return_offsets; | 114 | std::vector<unsigned> return_offsets; |