mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-07-04 23:31:19 +01:00
Merge pull request #3651 from ReinUsesLisp/line-widths
gl_rasterizer: Implement line widths and smooth lines
This commit is contained in:
commit
fbf13d3f48
5 changed files with 33 additions and 2 deletions
|
@ -966,7 +966,10 @@ public:
|
||||||
BitField<4, 1, u32> triangle_rast_flip;
|
BitField<4, 1, u32> triangle_rast_flip;
|
||||||
} screen_y_control;
|
} screen_y_control;
|
||||||
|
|
||||||
INSERT_UNION_PADDING_WORDS(0x21);
|
float line_width_smooth;
|
||||||
|
float line_width_aliased;
|
||||||
|
|
||||||
|
INSERT_UNION_PADDING_WORDS(0x1F);
|
||||||
|
|
||||||
u32 vb_element_base;
|
u32 vb_element_base;
|
||||||
u32 vb_base_instance;
|
u32 vb_base_instance;
|
||||||
|
@ -1024,7 +1027,7 @@ public:
|
||||||
|
|
||||||
float polygon_offset_factor;
|
float polygon_offset_factor;
|
||||||
|
|
||||||
INSERT_UNION_PADDING_WORDS(0x1);
|
u32 line_smooth_enable;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
u32 tic_address_high;
|
u32 tic_address_high;
|
||||||
|
@ -1591,6 +1594,8 @@ ASSERT_REG_POSITION(stencil_front_func_mask, 0x4E6);
|
||||||
ASSERT_REG_POSITION(stencil_front_mask, 0x4E7);
|
ASSERT_REG_POSITION(stencil_front_mask, 0x4E7);
|
||||||
ASSERT_REG_POSITION(frag_color_clamp, 0x4EA);
|
ASSERT_REG_POSITION(frag_color_clamp, 0x4EA);
|
||||||
ASSERT_REG_POSITION(screen_y_control, 0x4EB);
|
ASSERT_REG_POSITION(screen_y_control, 0x4EB);
|
||||||
|
ASSERT_REG_POSITION(line_width_smooth, 0x4EC);
|
||||||
|
ASSERT_REG_POSITION(line_width_aliased, 0x4ED);
|
||||||
ASSERT_REG_POSITION(vb_element_base, 0x50D);
|
ASSERT_REG_POSITION(vb_element_base, 0x50D);
|
||||||
ASSERT_REG_POSITION(vb_base_instance, 0x50E);
|
ASSERT_REG_POSITION(vb_base_instance, 0x50E);
|
||||||
ASSERT_REG_POSITION(clip_distance_enabled, 0x544);
|
ASSERT_REG_POSITION(clip_distance_enabled, 0x544);
|
||||||
|
@ -1604,6 +1609,7 @@ ASSERT_REG_POSITION(multisample_control, 0x54F);
|
||||||
ASSERT_REG_POSITION(condition, 0x554);
|
ASSERT_REG_POSITION(condition, 0x554);
|
||||||
ASSERT_REG_POSITION(tsc, 0x557);
|
ASSERT_REG_POSITION(tsc, 0x557);
|
||||||
ASSERT_REG_POSITION(polygon_offset_factor, 0x55B);
|
ASSERT_REG_POSITION(polygon_offset_factor, 0x55B);
|
||||||
|
ASSERT_REG_POSITION(line_smooth_enable, 0x55C);
|
||||||
ASSERT_REG_POSITION(tic, 0x55D);
|
ASSERT_REG_POSITION(tic, 0x55D);
|
||||||
ASSERT_REG_POSITION(stencil_two_side_enable, 0x565);
|
ASSERT_REG_POSITION(stencil_two_side_enable, 0x565);
|
||||||
ASSERT_REG_POSITION(stencil_back_op_fail, 0x566);
|
ASSERT_REG_POSITION(stencil_back_op_fail, 0x566);
|
||||||
|
|
|
@ -496,6 +496,7 @@ void RasterizerOpenGL::Draw(bool is_indexed, bool is_instanced) {
|
||||||
SyncPrimitiveRestart();
|
SyncPrimitiveRestart();
|
||||||
SyncScissorTest();
|
SyncScissorTest();
|
||||||
SyncPointState();
|
SyncPointState();
|
||||||
|
SyncLineState();
|
||||||
SyncPolygonOffset();
|
SyncPolygonOffset();
|
||||||
SyncAlphaTest();
|
SyncAlphaTest();
|
||||||
SyncFramebufferSRGB();
|
SyncFramebufferSRGB();
|
||||||
|
@ -1311,6 +1312,19 @@ void RasterizerOpenGL::SyncPointState() {
|
||||||
glDisable(GL_PROGRAM_POINT_SIZE);
|
glDisable(GL_PROGRAM_POINT_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RasterizerOpenGL::SyncLineState() {
|
||||||
|
auto& gpu = system.GPU().Maxwell3D();
|
||||||
|
auto& flags = gpu.dirty.flags;
|
||||||
|
if (!flags[Dirty::LineWidth]) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
flags[Dirty::LineWidth] = false;
|
||||||
|
|
||||||
|
const auto& regs = gpu.regs;
|
||||||
|
oglEnable(GL_LINE_SMOOTH, regs.line_smooth_enable);
|
||||||
|
glLineWidth(regs.line_smooth_enable ? regs.line_width_smooth : regs.line_width_aliased);
|
||||||
|
}
|
||||||
|
|
||||||
void RasterizerOpenGL::SyncPolygonOffset() {
|
void RasterizerOpenGL::SyncPolygonOffset() {
|
||||||
auto& gpu = system.GPU().Maxwell3D();
|
auto& gpu = system.GPU().Maxwell3D();
|
||||||
auto& flags = gpu.dirty.flags;
|
auto& flags = gpu.dirty.flags;
|
||||||
|
|
|
@ -171,6 +171,9 @@ private:
|
||||||
/// Syncs the point state to match the guest state
|
/// Syncs the point state to match the guest state
|
||||||
void SyncPointState();
|
void SyncPointState();
|
||||||
|
|
||||||
|
/// Syncs the line state to match the guest state
|
||||||
|
void SyncLineState();
|
||||||
|
|
||||||
/// Syncs the rasterizer enable state to match the guest state
|
/// Syncs the rasterizer enable state to match the guest state
|
||||||
void SyncRasterizeEnable();
|
void SyncRasterizeEnable();
|
||||||
|
|
||||||
|
|
|
@ -185,6 +185,12 @@ void SetupDirtyPointSize(Tables& tables) {
|
||||||
tables[0][OFF(point_sprite_enable)] = PointSize;
|
tables[0][OFF(point_sprite_enable)] = PointSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetupDirtyLineWidth(Tables& tables) {
|
||||||
|
tables[0][OFF(line_width_smooth)] = LineWidth;
|
||||||
|
tables[0][OFF(line_width_aliased)] = LineWidth;
|
||||||
|
tables[0][OFF(line_smooth_enable)] = LineWidth;
|
||||||
|
}
|
||||||
|
|
||||||
void SetupDirtyClipControl(Tables& tables) {
|
void SetupDirtyClipControl(Tables& tables) {
|
||||||
auto& table = tables[0];
|
auto& table = tables[0];
|
||||||
table[OFF(screen_y_control)] = ClipControl;
|
table[OFF(screen_y_control)] = ClipControl;
|
||||||
|
@ -233,6 +239,7 @@ void StateTracker::Initialize() {
|
||||||
SetupDirtyLogicOp(tables);
|
SetupDirtyLogicOp(tables);
|
||||||
SetupDirtyFragmentClampColor(tables);
|
SetupDirtyFragmentClampColor(tables);
|
||||||
SetupDirtyPointSize(tables);
|
SetupDirtyPointSize(tables);
|
||||||
|
SetupDirtyLineWidth(tables);
|
||||||
SetupDirtyClipControl(tables);
|
SetupDirtyClipControl(tables);
|
||||||
SetupDirtyDepthClampEnabled(tables);
|
SetupDirtyDepthClampEnabled(tables);
|
||||||
SetupDirtyMisc(tables);
|
SetupDirtyMisc(tables);
|
||||||
|
|
|
@ -78,6 +78,7 @@ enum : u8 {
|
||||||
LogicOp,
|
LogicOp,
|
||||||
FragmentClampColor,
|
FragmentClampColor,
|
||||||
PointSize,
|
PointSize,
|
||||||
|
LineWidth,
|
||||||
ClipControl,
|
ClipControl,
|
||||||
DepthClampEnabled,
|
DepthClampEnabled,
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue