mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-28 13:56:59 +01:00
Translate NGG mesh prolog with guest wave32 width
This commit is contained in:
@@ -1063,8 +1063,8 @@ IR::Program TranslateProgram(const Decoder::Program& decoded, const CFG::Graph&
|
|||||||
}
|
}
|
||||||
} else if (options.stage == ShaderType::Mesh) {
|
} else if (options.stage == ShaderType::Mesh) {
|
||||||
const auto& mesh = options.input_info.vertex->mesh;
|
const auto& mesh = options.input_info.vertex->mesh;
|
||||||
EXIT_NOT_IMPLEMENTED(options.wave_size != 64u || mesh.primitives_per_group == 0u ||
|
EXIT_NOT_IMPLEMENTED(mesh.primitives_per_group == 0u || mesh.vertices_per_group > 64u ||
|
||||||
mesh.vertices_per_group > 64u || total_threads > 15u * 64u);
|
total_threads > 15u * options.wave_size);
|
||||||
const auto u32 = [](uint32_t value) { return IR::U32(IR::Value(value)); };
|
const auto u32 = [](uint32_t value) { return IR::U32(IR::Value(value)); };
|
||||||
const auto draw = [&](uint32_t index) {
|
const auto draw = [&](uint32_t index) {
|
||||||
return IR::U32(
|
return IR::U32(
|
||||||
@@ -1089,12 +1089,15 @@ IR::Program TranslateProgram(const Decoder::Program& decoded, const CFG::Graph&
|
|||||||
entry_ir.IAdd(IR::U32(entry_ir.Emit(IR::ValueOpcode::UDiv32,
|
entry_ir.IAdd(IR::U32(entry_ir.Emit(IR::ValueOpcode::UDiv32,
|
||||||
{subtract_saturate(vertices, size), step})),
|
{subtract_saturate(vertices, size), step})),
|
||||||
u32(1)));
|
u32(1)));
|
||||||
const auto wave = entry_ir.ShiftRightLogical(local, u32(6));
|
const auto wave = entry_ir.ShiftRightLogical(local, u32(options.wave_size == 32u ? 5u : 6u));
|
||||||
const auto wave_base = entry_ir.BitwiseAnd(local, u32(~63u));
|
const auto wave_base = entry_ir.BitwiseAnd(local, u32(~(options.wave_size - 1u)));
|
||||||
const auto vertex_count = minimum(subtract_saturate(vertices, wave_base), u32(64));
|
const auto vertex_count =
|
||||||
const auto primitive_count = minimum(subtract_saturate(primitives, wave_base), u32(64));
|
minimum(subtract_saturate(vertices, wave_base), u32(options.wave_size));
|
||||||
|
const auto primitive_count =
|
||||||
|
minimum(subtract_saturate(primitives, wave_base), u32(options.wave_size));
|
||||||
const auto wave_info = entry_ir.BitwiseOr(entry_ir.ShiftLeftLogical(wave, u32(24)),
|
const auto wave_info = entry_ir.BitwiseOr(entry_ir.ShiftLeftLogical(wave, u32(24)),
|
||||||
u32(((total_threads + 63u) / 64u) << 28u));
|
u32(((total_threads + options.wave_size - 1u) /
|
||||||
|
options.wave_size) << 28u));
|
||||||
entry_ir.SetScalarReg(
|
entry_ir.SetScalarReg(
|
||||||
static_cast<IR::ScalarReg>(3),
|
static_cast<IR::ScalarReg>(3),
|
||||||
entry_ir.BitwiseOr(wave_info, entry_ir.BitwiseOr(entry_ir.ShiftLeftLogical(
|
entry_ir.BitwiseOr(wave_info, entry_ir.BitwiseOr(entry_ir.ShiftLeftLogical(
|
||||||
|
|||||||
@@ -9885,6 +9885,7 @@ void TestMeshInputAssembly() {
|
|||||||
uint32_t capacity, count, group, lane, width, address_low, base_vertex;
|
uint32_t capacity, count, group, lane, width, address_low, base_vertex;
|
||||||
uint32_t wave_info, first, second, third, byte_offset, vertex_id;
|
uint32_t wave_info, first, second, third, byte_offset, vertex_id;
|
||||||
bool fetch;
|
bool fetch;
|
||||||
|
uint32_t wave_size = 64;
|
||||||
};
|
};
|
||||||
const Case cases[] = {
|
const Case cases[] = {
|
||||||
{Prospero::PrimitiveType::kTriList, 14, 177, 14, 2, 2, 0x1002, UINT32_MAX,
|
{Prospero::PrimitiveType::kTriList, 14, 177, 14, 2, 2, 0x1002, UINT32_MAX,
|
||||||
@@ -9931,11 +9932,14 @@ void TestMeshInputAssembly() {
|
|||||||
0x40000c0c, 1, 0, 0, 52, 0xabcd0128, true},
|
0x40000c0c, 1, 0, 0, 52, 0xabcd0128, true},
|
||||||
{Prospero::PrimitiveType::kPointList, 12, 265, 1, 64, 4, 0x1000, 0,
|
{Prospero::PrimitiveType::kPointList, 12, 265, 1, 64, 4, 0x1000, 0,
|
||||||
0x41000000, 64, 0, 0, 304, 0, false},
|
0x41000000, 64, 0, 0, 304, 0, false},
|
||||||
|
{Prospero::PrimitiveType::kTriStrip, 40, 40, 0, 32, 0, 0, 11,
|
||||||
|
0x81000608, 32, 33, 34, 0, 43, false, 32},
|
||||||
};
|
};
|
||||||
for (const auto &test : cases) {
|
for (const auto &test : cases) {
|
||||||
ShaderVertexInputInfo input{};
|
ShaderVertexInputInfo input{};
|
||||||
auto &mesh = input.mesh;
|
auto &mesh = input.mesh;
|
||||||
mesh.input_primitive = static_cast<uint32_t>(test.topology);
|
mesh.input_primitive = static_cast<uint32_t>(test.topology);
|
||||||
|
mesh.wave_size = test.wave_size;
|
||||||
mesh.primitives_per_group = mesh.InputPrimitiveCount(test.capacity);
|
mesh.primitives_per_group = mesh.InputPrimitiveCount(test.capacity);
|
||||||
mesh.vertices_per_group = mesh.InputVertexCount(mesh.primitives_per_group);
|
mesh.vertices_per_group = mesh.InputVertexCount(mesh.primitives_per_group);
|
||||||
mesh.threads_num[0] = 256;
|
mesh.threads_num[0] = 256;
|
||||||
@@ -9949,7 +9953,7 @@ void TestMeshInputAssembly() {
|
|||||||
graph.entry_block = 0;
|
graph.entry_block = 0;
|
||||||
Frontend::TranslateOptions options{};
|
Frontend::TranslateOptions options{};
|
||||||
options.stage = ShaderType::Mesh;
|
options.stage = ShaderType::Mesh;
|
||||||
options.wave_size = 64;
|
options.wave_size = test.wave_size;
|
||||||
options.user_data_count = 0;
|
options.user_data_count = 0;
|
||||||
options.input_info.vertex = &input;
|
options.input_info.vertex = &input;
|
||||||
auto program = Frontend::TranslateProgram(decoded, graph, options);
|
auto program = Frontend::TranslateProgram(decoded, graph, options);
|
||||||
|
|||||||
Reference in New Issue
Block a user