mirror of
https://github.com/RPCS3/rpcs3.git
synced 2026-03-11 16:05:23 +01:00
[rsx/dx12/vk/ogl] Refactor blend constants fetch; properly fill blend constants for vulkan
This commit is contained in:
parent
6ef87d39f6
commit
77ada8e7dc
|
|
@ -6,6 +6,7 @@
|
|||
#include "D3D12GSRender.h"
|
||||
#include "D3D12Formats.h"
|
||||
#include "../rsx_methods.h"
|
||||
#include "../rsx_utils.h"
|
||||
|
||||
#define TO_STRING(x) #x
|
||||
|
||||
|
|
@ -93,21 +94,7 @@ void D3D12GSRender::load_program()
|
|||
D3D12_BLEND d3d_sfactor_alpha = get_blend_factor_alpha(sfactor_a);
|
||||
D3D12_BLEND d3d_dfactor_alpha = get_blend_factor_alpha(dfactor_a);
|
||||
|
||||
FLOAT BlendColor[4];
|
||||
|
||||
//TODO: Check surface color format for u16 colors
|
||||
{
|
||||
u8 blend_color_r = rsx::method_registers.blend_color_8b_r();
|
||||
u8 blend_color_g = rsx::method_registers.blend_color_8b_g();
|
||||
u8 blend_color_b = rsx::method_registers.blend_color_8b_b();
|
||||
u8 blend_color_a = rsx::method_registers.blend_color_8b_a();
|
||||
|
||||
BlendColor[0] = blend_color_r / 255.f;
|
||||
BlendColor[1] = blend_color_g / 255.f;
|
||||
BlendColor[2] = blend_color_b / 255.f;
|
||||
BlendColor[3] = blend_color_a / 255.f;
|
||||
}
|
||||
|
||||
auto BlendColor = rsx::get_constant_blend_colors();
|
||||
bool color_blend_possible = true;
|
||||
|
||||
if (sfactor_rgb == rsx::blend_factor::constant_alpha ||
|
||||
|
|
@ -149,7 +136,7 @@ void D3D12GSRender::load_program()
|
|||
}
|
||||
else
|
||||
{
|
||||
get_current_resource_storage().command_list->OMSetBlendFactor(BlendColor);
|
||||
get_current_resource_storage().command_list->OMSetBlendFactor(BlendColor.data());
|
||||
}
|
||||
|
||||
prop.Blend.RenderTarget[0].BlendEnable = true;
|
||||
|
|
|
|||
|
|
@ -223,24 +223,8 @@ void GLGSRender::begin()
|
|||
blend_factor(rsx::method_registers.blend_func_sfactor_a()),
|
||||
blend_factor(rsx::method_registers.blend_func_dfactor_a()));
|
||||
|
||||
if (rsx::method_registers.surface_color() == rsx::surface_color_format::w16z16y16x16) //TODO: check another color formats
|
||||
{
|
||||
u16 blend_color_r = rsx::method_registers.blend_color_16b_r();
|
||||
u16 blend_color_g = rsx::method_registers.blend_color_16b_g();
|
||||
u16 blend_color_b = rsx::method_registers.blend_color_16b_b();
|
||||
u16 blend_color_a = rsx::method_registers.blend_color_16b_a();
|
||||
|
||||
__glcheck glBlendColor(blend_color_r / 65535.f, blend_color_g / 65535.f, blend_color_b / 65535.f, blend_color_a / 65535.f);
|
||||
}
|
||||
else
|
||||
{
|
||||
u8 blend_color_r = rsx::method_registers.blend_color_8b_r();
|
||||
u8 blend_color_g = rsx::method_registers.blend_color_8b_g();
|
||||
u8 blend_color_b = rsx::method_registers.blend_color_8b_b();
|
||||
u8 blend_color_a = rsx::method_registers.blend_color_8b_a();
|
||||
|
||||
__glcheck glBlendColor(blend_color_r / 255.f, blend_color_g / 255.f, blend_color_b / 255.f, blend_color_a / 255.f);
|
||||
}
|
||||
auto blend_colors = rsx::get_constant_blend_colors();
|
||||
__glcheck glBlendColor(blend_colors[0], blend_colors[1], blend_colors[2], blend_colors[3]);
|
||||
|
||||
__glcheck glBlendEquationSeparate(blend_equation(rsx::method_registers.blend_equation_rgb()),
|
||||
blend_equation(rsx::method_registers.blend_equation_a()));
|
||||
|
|
|
|||
|
|
@ -1047,7 +1047,6 @@ bool VKGSRender::load_program()
|
|||
VkBlendOp equation_rgb = vk::get_blend_op(rsx::method_registers.blend_equation_rgb());
|
||||
VkBlendOp equation_a = vk::get_blend_op(rsx::method_registers.blend_equation_a());
|
||||
|
||||
//TODO: Separate target blending
|
||||
for (u8 idx = 0; idx < m_draw_buffers_count; ++idx)
|
||||
{
|
||||
properties.att_state[render_targets[idx]].blendEnable = VK_TRUE;
|
||||
|
|
@ -1058,6 +1057,12 @@ bool VKGSRender::load_program()
|
|||
properties.att_state[render_targets[idx]].colorBlendOp = equation_rgb;
|
||||
properties.att_state[render_targets[idx]].alphaBlendOp = equation_a;
|
||||
}
|
||||
|
||||
auto blend_colors = rsx::get_constant_blend_colors();
|
||||
properties.cs.blendConstants[0] = blend_colors[0];
|
||||
properties.cs.blendConstants[1] = blend_colors[1];
|
||||
properties.cs.blendConstants[2] = blend_colors[2];
|
||||
properties.cs.blendConstants[3] = blend_colors[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -105,4 +105,28 @@ namespace rsx
|
|||
|
||||
fill_scale_offset_matrix(buffer, transpose, offset_x, offset_y, offset_z, scale_x, scale_y, scale_z);
|
||||
}
|
||||
|
||||
//Convert decoded integer values for CONSTANT_BLEND_FACTOR into f32 array in 0-1 range
|
||||
std::array<float, 4> get_constant_blend_colors()
|
||||
{
|
||||
//TODO: check another color formats (probably all integer formats with > 8-bits wide channels)
|
||||
if (rsx::method_registers.surface_color() == rsx::surface_color_format::w16z16y16x16)
|
||||
{
|
||||
u16 blend_color_r = rsx::method_registers.blend_color_16b_r();
|
||||
u16 blend_color_g = rsx::method_registers.blend_color_16b_g();
|
||||
u16 blend_color_b = rsx::method_registers.blend_color_16b_b();
|
||||
u16 blend_color_a = rsx::method_registers.blend_color_16b_a();
|
||||
|
||||
return { blend_color_r / 65535.f, blend_color_g / 65535.f, blend_color_b / 65535.f, blend_color_a / 65535.f };
|
||||
}
|
||||
else
|
||||
{
|
||||
u8 blend_color_r = rsx::method_registers.blend_color_8b_r();
|
||||
u8 blend_color_g = rsx::method_registers.blend_color_8b_g();
|
||||
u8 blend_color_b = rsx::method_registers.blend_color_8b_b();
|
||||
u8 blend_color_a = rsx::method_registers.blend_color_8b_a();
|
||||
|
||||
return { blend_color_r / 255.f, blend_color_g / 255.f, blend_color_b / 255.f, blend_color_a / 255.f };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -120,4 +120,6 @@ namespace rsx
|
|||
float scale_x, float scale_y, float scale_z);
|
||||
void fill_window_matrix(void *dest, bool transpose);
|
||||
void fill_viewport_matrix(void *buffer, bool transpose);
|
||||
|
||||
std::array<float, 4> get_constant_blend_colors();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue