[GPU] Eliminate unused shader I/O, UCP culling, centroid on Vulkan

For more optimal usage of exports and the parameter cache on the host regardless of how effective the optimizations in the host GPU driver are. Also reserve space for Vulkan/Metal/D3D11-specific HostVertexShaderTypes to use one more bit for the host vertex shader type in the shader modification bits, so that won't have to be done in the future as that would require invalidating shader storages (which are invalidated by this commit) again.
This commit is contained in:
Triang3l
2022-07-21 12:32:28 +03:00
parent 0a94b86cb8
commit 1a95bef8b3
22 changed files with 3366 additions and 3235 deletions

View File

@@ -233,6 +233,26 @@ void Shader::AnalyzeUcode(StringBuffer& ucode_disasm_buffer) {
}
}
uint32_t Shader::GetInterpolatorInputMask(reg::SQ_PROGRAM_CNTL sq_program_cntl,
reg::SQ_CONTEXT_MISC sq_context_misc,
uint32_t& param_gen_pos_out) const {
assert_true(type() == xenos::ShaderType::kPixel);
uint32_t interpolator_count = std::min(
xenos::kMaxInterpolators,
std::max(register_static_address_bound(),
GetDynamicAddressableRegisterCount(sq_program_cntl.ps_num_reg)));
uint32_t interpolator_mask = (UINT32_C(1) << interpolator_count) - 1;
if (sq_program_cntl.param_gen &&
sq_context_misc.param_gen_pos < interpolator_count) {
// Will be overwritten by PsParamGen.
interpolator_mask &= ~(UINT32_C(1) << sq_context_misc.param_gen_pos);
param_gen_pos_out = sq_context_misc.param_gen_pos;
} else {
param_gen_pos_out = UINT32_MAX;
}
return interpolator_mask;
}
void Shader::GatherExecInformation(
const ParsedExecInstruction& instr,
ucode::VertexFetchInstruction& previous_vfetch_full,
@@ -470,7 +490,8 @@ void Shader::GatherFetchResultInformation(const InstructionResult& result) {
void Shader::GatherAluResultInformation(
const InstructionResult& result, uint32_t memexport_alloc_current_count) {
if (!result.GetUsedWriteMask()) {
uint32_t used_write_mask = result.GetUsedWriteMask();
if (!used_write_mask) {
return;
}
switch (result.storage_target) {
@@ -483,6 +504,12 @@ void Shader::GatherAluResultInformation(
uses_register_dynamic_addressing_ = true;
}
break;
case InstructionStorageTarget::kInterpolator:
writes_interpolators_ |= uint32_t(1) << result.storage_index;
break;
case InstructionStorageTarget::kPointSizeEdgeFlagKillVertex:
writes_point_size_edge_flag_kill_vertex_ |= used_write_mask;
break;
case InstructionStorageTarget::kExportData:
if (memexport_alloc_current_count > 0 &&
memexport_alloc_current_count <= Shader::kMaxMemExports) {