mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-27 16:02:37 +00:00
graphics: derive compute wave size from dispatch mode
This commit is contained in:
1 parent
69156b2f0e
commit
a42e3bb09e
7 files changed
+22
-27
No files matched your search
@@ -1360,10 +1360,6 @@ static void HwShSetCsRegister(CommandProcessor& cp, uint32_t cmd_offset, uint32_
|
|||||||
Pm4::COMPUTE_PGM_RSRC1_BULKY_MASK) != 0u;
|
Pm4::COMPUTE_PGM_RSRC1_BULKY_MASK) != 0u;
|
||||||
cs_regs.threadgroup_configuration = ((value >> Pm4::COMPUTE_PGM_RSRC1_WGP_MODE_SHIFT) &
|
cs_regs.threadgroup_configuration = ((value >> Pm4::COMPUTE_PGM_RSRC1_WGP_MODE_SHIFT) &
|
||||||
Pm4::COMPUTE_PGM_RSRC1_WGP_MODE_MASK) != 0u;
|
Pm4::COMPUTE_PGM_RSRC1_WGP_MODE_MASK) != 0u;
|
||||||
cs_regs.wave_size = (((value >> Pm4::COMPUTE_PGM_RSRC1_W32_EN_SHIFT) &
|
|
||||||
Pm4::COMPUTE_PGM_RSRC1_W32_EN_MASK) != 0u)
|
|
||||||
? 32u
|
|
||||||
: 64u;
|
|
||||||
break;
|
break;
|
||||||
case Pm4::COMPUTE_PGM_RSRC2:
|
case Pm4::COMPUTE_PGM_RSRC2:
|
||||||
cs_regs.scratch_en = ((value >> Pm4::COMPUTE_PGM_RSRC2_SCRATCH_EN_SHIFT) &
|
cs_regs.scratch_en = ((value >> Pm4::COMPUTE_PGM_RSRC2_SCRATCH_EN_SHIFT) &
|
||||||
|
|||||||
@@ -1108,6 +1108,8 @@ void CommandProcessor::DrawIndirectMulti(uint32_t data_offset, uint32_t max_coun
|
|||||||
|
|
||||||
void CommandProcessor::DispatchDirect(uint32_t thread_group_x, uint32_t thread_group_y,
|
void CommandProcessor::DispatchDirect(uint32_t thread_group_x, uint32_t thread_group_y,
|
||||||
uint32_t thread_group_z, uint32_t mode) {
|
uint32_t thread_group_z, uint32_t mode) {
|
||||||
|
m_sh_ctx.SetCsWaveSize(Pm4::ComputeWaveSize(mode));
|
||||||
|
|
||||||
uint32_t frame_num = 0;
|
uint32_t frame_num = 0;
|
||||||
// uint32_t local_x = 1;
|
// uint32_t local_x = 1;
|
||||||
// uint32_t local_y = 1;
|
// uint32_t local_y = 1;
|
||||||
|
|||||||
@@ -1089,6 +1089,7 @@ public:
|
|||||||
void SetPsShaderChksum(uint32_t value) { m_ps.ps_regs.chksum = value; }
|
void SetPsShaderChksum(uint32_t value) { m_ps.ps_regs.chksum = value; }
|
||||||
|
|
||||||
void SetCsShader(const CsStageRegisters& cs_regs) { m_cs.cs_regs = cs_regs; }
|
void SetCsShader(const CsStageRegisters& cs_regs) { m_cs.cs_regs = cs_regs; }
|
||||||
|
void SetCsWaveSize(uint8_t wave_size) { m_cs.cs_regs.wave_size = wave_size; }
|
||||||
|
|
||||||
void SetPsUserSgpr(uint32_t id, uint32_t value, UserSgprType type) {
|
void SetPsUserSgpr(uint32_t id, uint32_t value, UserSgprType type) {
|
||||||
m_ps.ps_user_sgpr.value[id] = value;
|
m_ps.ps_user_sgpr.value[id] = value;
|
||||||
|
|||||||
@@ -984,8 +984,16 @@ constexpr uint32_t COMPUTE_PGM_RSRC1_FP16_OVFL_SHIFT = 26;
|
|||||||
constexpr uint32_t COMPUTE_PGM_RSRC1_FP16_OVFL_MASK = 0x1;
|
constexpr uint32_t COMPUTE_PGM_RSRC1_FP16_OVFL_MASK = 0x1;
|
||||||
constexpr uint32_t COMPUTE_PGM_RSRC1_WGP_MODE_SHIFT = 29;
|
constexpr uint32_t COMPUTE_PGM_RSRC1_WGP_MODE_SHIFT = 29;
|
||||||
constexpr uint32_t COMPUTE_PGM_RSRC1_WGP_MODE_MASK = 0x1;
|
constexpr uint32_t COMPUTE_PGM_RSRC1_WGP_MODE_MASK = 0x1;
|
||||||
constexpr uint32_t COMPUTE_PGM_RSRC1_W32_EN_SHIFT = 30;
|
|
||||||
constexpr uint32_t COMPUTE_PGM_RSRC1_W32_EN_MASK = 0x1;
|
constexpr uint32_t COMPUTE_DISPATCH_INITIATOR_CS_W32_EN_SHIFT = 15;
|
||||||
|
constexpr uint32_t COMPUTE_DISPATCH_INITIATOR_CS_W32_EN_MASK = 0x1;
|
||||||
|
|
||||||
|
[[nodiscard]] constexpr uint8_t ComputeWaveSize(uint32_t dispatch_initiator) {
|
||||||
|
return ((dispatch_initiator >> COMPUTE_DISPATCH_INITIATOR_CS_W32_EN_SHIFT) &
|
||||||
|
COMPUTE_DISPATCH_INITIATOR_CS_W32_EN_MASK) != 0u
|
||||||
|
? 32u
|
||||||
|
: 64u;
|
||||||
|
}
|
||||||
|
|
||||||
constexpr uint32_t COMPUTE_PGM_RSRC2 = 0x213;
|
constexpr uint32_t COMPUTE_PGM_RSRC2 = 0x213;
|
||||||
constexpr uint32_t COMPUTE_PGM_RSRC2_SCRATCH_EN_SHIFT = 0;
|
constexpr uint32_t COMPUTE_PGM_RSRC2_SCRATCH_EN_SHIFT = 0;
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ bool ResolveComputeImageClear(const ShaderComputeInputInfo& input, uint32_t grou
|
|||||||
group_z == 1 && input.dispatch_threads_num[0] == group_x &&
|
group_z == 1 && input.dispatch_threads_num[0] == group_x &&
|
||||||
input.dispatch_threads_num[1] == 1 && input.dispatch_threads_num[2] == 1 &&
|
input.dispatch_threads_num[1] == 1 && input.dispatch_threads_num[2] == 1 &&
|
||||||
input.group_id[0] && !input.group_id[1] && !input.group_id[2] &&
|
input.group_id[0] && !input.group_id[1] && !input.group_id[2] &&
|
||||||
input.thread_ids_num == 1 && input.wave_size == 32 && !input.tg_size_en && mode == 0x61u &&
|
input.thread_ids_num == 1 && input.wave_size == 64 && !input.tg_size_en && mode == 0x61u &&
|
||||||
group_x % input.threads_num[0] == 0 && descriptor.NumRecords() == group_x;
|
group_x % input.threads_num[0] == 0 && descriptor.NumRecords() == group_x;
|
||||||
const auto size = BufferDescriptorSize(descriptor);
|
const auto size = BufferDescriptorSize(descriptor);
|
||||||
if (!full_dispatch || size == 0) {
|
if (!full_dispatch || size == 0) {
|
||||||
|
|||||||
@@ -18780,14 +18780,14 @@ void CheckPs5GameExampleImageClearRuntimeShape() {
|
|||||||
compute.dispatch_threads_num[2] = 1;
|
compute.dispatch_threads_num[2] = 1;
|
||||||
compute.group_id[0] = true;
|
compute.group_id[0] = true;
|
||||||
compute.dispatch_thread_dimensions = true;
|
compute.dispatch_thread_dimensions = true;
|
||||||
compute.wave_size = 32;
|
compute.wave_size = 64;
|
||||||
compute.thread_ids_num = 1;
|
compute.thread_ids_num = 1;
|
||||||
compute.workgroup_register = 8;
|
compute.workgroup_register = 8;
|
||||||
|
|
||||||
const auto Compile = [&](const char *stage, const std::vector<u32> &code) {
|
const auto Compile = [&](const char *stage, const std::vector<u32> &code) {
|
||||||
ShaderRecompiler::CompileOptions options;
|
ShaderRecompiler::CompileOptions options;
|
||||||
options.stage = ShaderType::Compute;
|
options.stage = ShaderType::Compute;
|
||||||
options.wave_size = 32;
|
options.wave_size = 64;
|
||||||
options.user_data_base = 0;
|
options.user_data_base = 0;
|
||||||
options.user_data_count = static_cast<u32>(user_data.size());
|
options.user_data_count = static_cast<u32>(user_data.size());
|
||||||
options.user_data = user_data.data();
|
options.user_data = user_data.data();
|
||||||
|
|||||||
@@ -8137,23 +8137,11 @@ void TestNewShaderRecompilerU64PairLowering() {
|
|||||||
"dispatcher did not use one canonical U64 vector spill slot");
|
"dispatcher did not use one canonical U64 vector spill slot");
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestComputeShaderInputWaveSize() {
|
void TestComputeDispatchWaveSize() {
|
||||||
const auto decode_wave_size = [](uint32_t rsrc1) {
|
Check(Pm4::ComputeWaveSize(0x00000041u) == 64u,
|
||||||
const bool wave32 = (((rsrc1 >> Pm4::COMPUTE_PGM_RSRC1_W32_EN_SHIFT) &
|
"dispatch without CS_W32_EN did not select wave64");
|
||||||
Pm4::COMPUTE_PGM_RSRC1_W32_EN_MASK) != 0u);
|
Check(Pm4::ComputeWaveSize(0x00008041u) == 32u,
|
||||||
return wave32 ? 32u : 64u;
|
"dispatch with CS_W32_EN did not select wave32");
|
||||||
};
|
|
||||||
|
|
||||||
constexpr uint32_t observed_wave32_rsrc1_a = 0x402c0146u;
|
|
||||||
constexpr uint32_t observed_wave32_rsrc1_b = 0x402c00c1u;
|
|
||||||
Check(decode_wave_size(observed_wave32_rsrc1_a) == 32u,
|
|
||||||
"COMPUTE_PGM_RSRC1 W32_EN bit did not match observed PS5 value A");
|
|
||||||
Check(decode_wave_size(observed_wave32_rsrc1_b) == 32u,
|
|
||||||
"COMPUTE_PGM_RSRC1 W32_EN bit did not match observed PS5 value B");
|
|
||||||
|
|
||||||
constexpr uint32_t w32_en_bit = 1u << Pm4::COMPUTE_PGM_RSRC1_W32_EN_SHIFT;
|
|
||||||
Check(decode_wave_size(observed_wave32_rsrc1_a & ~w32_en_bit) == 64u,
|
|
||||||
"cleared COMPUTE_PGM_RSRC1 W32_EN bit did not decode as wave64");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestNewShaderRecompilerBufferLoadsGuardedByExec() {
|
void TestNewShaderRecompilerBufferLoadsGuardedByExec() {
|
||||||
@@ -11581,7 +11569,7 @@ int main() {
|
|||||||
TestNewShaderRecompilerCfgIrreducibleDispatcher();
|
TestNewShaderRecompilerCfgIrreducibleDispatcher();
|
||||||
TestNewShaderRecompilerDispatcherSpillsU32x3();
|
TestNewShaderRecompilerDispatcherSpillsU32x3();
|
||||||
TestNewShaderRecompilerU64PairLowering();
|
TestNewShaderRecompilerU64PairLowering();
|
||||||
TestComputeShaderInputWaveSize();
|
TestComputeDispatchWaveSize();
|
||||||
TestNewShaderRecompilerBufferLoadsGuardedByExec();
|
TestNewShaderRecompilerBufferLoadsGuardedByExec();
|
||||||
TestNewShaderRecompilerBufferAtomicsGuardedByBounds();
|
TestNewShaderRecompilerBufferAtomicsGuardedByBounds();
|
||||||
TestNewShaderRecompilerPixelImageSampleLodSelection();
|
TestNewShaderRecompilerPixelImageSampleLodSelection();
|
||||||
|
|||||||
Reference in new issue
Block a user