[Vulkan] PsParamGen

This commit is contained in:
Triang3l
2022-06-26 15:01:27 +03:00
parent a99a1be880
commit 6688b13773
5 changed files with 212 additions and 6 deletions

View File

@@ -2336,7 +2336,8 @@ bool VulkanCommandProcessor::IssueDraw(xenos::PrimitiveType prim_type,
normalized_depth_control);
// Update system constants before uploading them.
UpdateSystemConstantValues(primitive_processing_result.host_index_endian,
UpdateSystemConstantValues(primitive_polygonal,
primitive_processing_result.host_index_endian,
viewport_info, used_texture_mask);
// Update uniform buffers and descriptor sets after binding the pipeline with
@@ -3257,14 +3258,15 @@ void VulkanCommandProcessor::UpdateDynamicState(
}
void VulkanCommandProcessor::UpdateSystemConstantValues(
xenos::Endian index_endian, const draw_util::ViewportInfo& viewport_info,
uint32_t used_texture_mask) {
bool primitive_polygonal, xenos::Endian index_endian,
const draw_util::ViewportInfo& viewport_info, uint32_t used_texture_mask) {
#if XE_UI_VULKAN_FINE_GRAINED_DRAW_SCOPES
SCOPE_profile_cpu_f("gpu");
#endif // XE_UI_VULKAN_FINE_GRAINED_DRAW_SCOPES
const RegisterFile& regs = *register_file_;
auto pa_cl_vte_cntl = regs.Get<reg::PA_CL_VTE_CNTL>();
auto vgt_draw_initiator = regs.Get<reg::VGT_DRAW_INITIATOR>();
int32_t vgt_indx_offset = int32_t(regs[XE_GPU_REG_VGT_INDX_OFFSET].u32);
// Get the color info register values for each render target.
@@ -3295,6 +3297,14 @@ void VulkanCommandProcessor::UpdateSystemConstantValues(
if (pa_cl_vte_cntl.vtx_w0_fmt) {
flags |= SpirvShaderTranslator::kSysFlag_WNotReciprocal;
}
// Whether the primitive is polygonal, and gl_FrontFacing matters.
if (primitive_polygonal) {
flags |= SpirvShaderTranslator::kSysFlag_PrimitivePolygonal;
}
// Primitive type.
if (draw_util::IsPrimitiveLine(regs)) {
flags |= SpirvShaderTranslator::kSysFlag_PrimitiveLine;
}
// Gamma writing.
// TODO(Triang3l): Gamma as sRGB check.
for (uint32_t i = 0; i < xenos::kMaxColorRenderTargets; ++i) {

View File

@@ -449,7 +449,8 @@ class VulkanCommandProcessor : public CommandProcessor {
void UpdateDynamicState(const draw_util::ViewportInfo& viewport_info,
bool primitive_polygonal,
reg::RB_DEPTHCONTROL normalized_depth_control);
void UpdateSystemConstantValues(xenos::Endian index_endian,
void UpdateSystemConstantValues(bool primitive_polygonal,
xenos::Endian index_endian,
const draw_util::ViewportInfo& viewport_info,
uint32_t used_texture_mask);
bool UpdateBindings(const VulkanShader* vertex_shader,

View File

@@ -134,13 +134,27 @@ VulkanPipelineCache::GetCurrentPixelShaderModification(
assert_true(shader.type() == xenos::ShaderType::kPixel);
assert_true(shader.is_ucode_analyzed());
const auto& regs = register_file_;
auto sq_program_cntl = regs.Get<reg::SQ_PROGRAM_CNTL>();
SpirvShaderTranslator::Modification modification(
shader_translator_->GetDefaultPixelShaderModification(
shader.GetDynamicAddressableRegisterCount(
sq_program_cntl.ps_num_reg)));
if (sq_program_cntl.param_gen) {
auto sq_context_misc = regs.Get<reg::SQ_CONTEXT_MISC>();
if (sq_context_misc.param_gen_pos <
std::min(std::max(modification.pixel.dynamic_addressable_register_count,
shader.register_static_address_bound()),
xenos::kMaxInterpolators)) {
modification.pixel.param_gen_enable = 1;
modification.pixel.param_gen_interpolator = sq_context_misc.param_gen_pos;
auto vgt_draw_initiator = regs.Get<reg::VGT_DRAW_INITIATOR>();
modification.pixel.param_gen_point = uint32_t(
vgt_draw_initiator.prim_type == xenos::PrimitiveType::kPointList);
}
}
return modification;
}