Skip to content

Commit 7c6490e

Browse files
committed
Revert "recompiler: fixed fragment shader built-in attribute access (shadps4-emu#1676)"
This reverts commit 8eacb88. Revert "semaphore: Add GCD semaphore implementation. (shadps4-emu#1677)" This reverts commit e1ecfb8.
1 parent 5f105db commit 7c6490e

File tree

5 files changed

+10
-136
lines changed

5 files changed

+10
-136
lines changed

src/core/libraries/kernel/sync/semaphore.h

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
#ifdef _WIN64
1313
#include <windows.h>
14-
#elif defined(__APPLE__)
15-
#include <dispatch/dispatch.h>
1614
#else
1715
#include <semaphore>
1816
#endif
@@ -23,32 +21,25 @@ template <s64 max>
2321
class Semaphore {
2422
public:
2523
Semaphore(s32 initialCount)
26-
#if !defined(_WIN64) && !defined(__APPLE__)
24+
#ifndef _WIN64
2725
: sem{initialCount}
2826
#endif
2927
{
3028
#ifdef _WIN64
3129
sem = CreateSemaphore(nullptr, initialCount, max, nullptr);
3230
ASSERT(sem);
33-
#elif defined(__APPLE__)
34-
sem = dispatch_semaphore_create(initialCount);
35-
ASSERT(sem);
3631
#endif
3732
}
3833

3934
~Semaphore() {
4035
#ifdef _WIN64
4136
CloseHandle(sem);
42-
#elif defined(__APPLE__)
43-
dispatch_release(sem);
4437
#endif
4538
}
4639

4740
void release() {
4841
#ifdef _WIN64
4942
ReleaseSemaphore(sem, 1, nullptr);
50-
#elif defined(__APPLE__)
51-
dispatch_semaphore_signal(sem);
5243
#else
5344
sem.release();
5445
#endif
@@ -62,13 +53,6 @@ class Semaphore {
6253
return;
6354
}
6455
}
65-
#elif defined(__APPLE__)
66-
for (;;) {
67-
const auto res = dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
68-
if (res == 0) {
69-
return;
70-
}
71-
}
7256
#else
7357
sem.acquire();
7458
#endif
@@ -77,8 +61,6 @@ class Semaphore {
7761
bool try_acquire() {
7862
#ifdef _WIN64
7963
return WaitForSingleObjectEx(sem, 0, true) == WAIT_OBJECT_0;
80-
#elif defined(__APPLE__)
81-
return dispatch_semaphore_wait(sem, DISPATCH_TIME_NOW) == 0;
8264
#else
8365
return sem.try_acquire();
8466
#endif
@@ -95,10 +77,6 @@ class Semaphore {
9577
}
9678

9779
return WaitForSingleObjectEx(sem, timeout_ms, true) == WAIT_OBJECT_0;
98-
#elif defined(__APPLE__)
99-
const auto rel_time_ns = std::chrono::ceil<std::chrono::nanoseconds>(rel_time).count();
100-
const auto timeout = dispatch_time(DISPATCH_TIME_NOW, rel_time_ns);
101-
return dispatch_semaphore_wait(sem, timeout) == 0;
10280
#else
10381
return sem.try_acquire_for(rel_time);
10482
#endif
@@ -120,16 +98,6 @@ class Semaphore {
12098

12199
u64 res = WaitForSingleObjectEx(sem, static_cast<u64>(timeout_ms), true);
122100
return res == WAIT_OBJECT_0;
123-
#elif defined(__APPLE__)
124-
auto abs_s = std::chrono::time_point_cast<std::chrono::seconds>(abs_time);
125-
auto abs_ns = std::chrono::time_point_cast<std::chrono::nanoseconds>(abs_time) -
126-
std::chrono::time_point_cast<std::chrono::nanoseconds>(abs_s);
127-
const timespec abs_timespec = {
128-
.tv_sec = abs_s.time_since_epoch().count(),
129-
.tv_nsec = abs_ns.count(),
130-
};
131-
const auto timeout = dispatch_walltime(&abs_timespec, 0);
132-
return dispatch_semaphore_wait(sem, timeout) == 0;
133101
#else
134102
return sem.try_acquire_until(abs_time);
135103
#endif
@@ -138,8 +106,6 @@ class Semaphore {
138106
private:
139107
#ifdef _WIN64
140108
HANDLE sem;
141-
#elif defined(__APPLE__)
142-
dispatch_semaphore_t sem;
143109
#else
144110
std::counting_semaphore<max> sem;
145111
#endif

src/shader_recompiler/frontend/translate/translate.cpp

Lines changed: 8 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -53,74 +53,15 @@ void Translator::EmitPrologue() {
5353
}
5454
break;
5555
case Stage::Fragment:
56-
dst_vreg = IR::VectorReg::V0;
57-
if (runtime_info.fs_info.addr_flags.persp_sample_ena) {
58-
++dst_vreg; // I
59-
++dst_vreg; // J
60-
}
61-
if (runtime_info.fs_info.addr_flags.persp_center_ena) {
62-
++dst_vreg; // I
63-
++dst_vreg; // J
64-
}
65-
if (runtime_info.fs_info.addr_flags.persp_centroid_ena) {
66-
++dst_vreg; // I
67-
++dst_vreg; // J
68-
}
69-
if (runtime_info.fs_info.addr_flags.persp_pull_model_ena) {
70-
++dst_vreg; // I/W
71-
++dst_vreg; // J/W
72-
++dst_vreg; // 1/W
73-
}
74-
if (runtime_info.fs_info.addr_flags.linear_sample_ena) {
75-
++dst_vreg; // I
76-
++dst_vreg; // J
77-
}
78-
if (runtime_info.fs_info.addr_flags.linear_center_ena) {
79-
++dst_vreg; // I
80-
++dst_vreg; // J
81-
}
82-
if (runtime_info.fs_info.addr_flags.linear_centroid_ena) {
83-
++dst_vreg; // I
84-
++dst_vreg; // J
85-
}
86-
if (runtime_info.fs_info.addr_flags.line_stipple_tex_ena) {
87-
++dst_vreg;
88-
}
89-
if (runtime_info.fs_info.addr_flags.pos_x_float_ena) {
90-
if (runtime_info.fs_info.en_flags.pos_x_float_ena) {
91-
ir.SetVectorReg(dst_vreg++, ir.GetAttribute(IR::Attribute::FragCoord, 0));
92-
} else {
93-
ir.SetVectorReg(dst_vreg++, ir.Imm32(0.0f));
94-
}
95-
}
96-
if (runtime_info.fs_info.addr_flags.pos_y_float_ena) {
97-
if (runtime_info.fs_info.en_flags.pos_y_float_ena) {
98-
ir.SetVectorReg(dst_vreg++, ir.GetAttribute(IR::Attribute::FragCoord, 1));
99-
} else {
100-
ir.SetVectorReg(dst_vreg++, ir.Imm32(0.0f));
101-
}
102-
}
103-
if (runtime_info.fs_info.addr_flags.pos_z_float_ena) {
104-
if (runtime_info.fs_info.en_flags.pos_z_float_ena) {
105-
ir.SetVectorReg(dst_vreg++, ir.GetAttribute(IR::Attribute::FragCoord, 2));
106-
} else {
107-
ir.SetVectorReg(dst_vreg++, ir.Imm32(0.0f));
108-
}
109-
}
110-
if (runtime_info.fs_info.addr_flags.pos_w_float_ena) {
111-
if (runtime_info.fs_info.en_flags.pos_w_float_ena) {
112-
ir.SetVectorReg(dst_vreg++, ir.GetAttribute(IR::Attribute::FragCoord, 3));
113-
} else {
114-
ir.SetVectorReg(dst_vreg++, ir.Imm32(0.0f));
115-
}
116-
}
117-
if (runtime_info.fs_info.addr_flags.front_face_ena) {
118-
if (runtime_info.fs_info.en_flags.front_face_ena) {
119-
ir.SetVectorReg(dst_vreg++, ir.GetAttributeU32(IR::Attribute::IsFrontFace));
120-
} else {
121-
ir.SetVectorReg(dst_vreg++, ir.Imm32(0));
122-
}
56+
// https://github.com/chaotic-cx/mesa-mirror/blob/72326e15/src/amd/vulkan/radv_shader_args.c#L258
57+
// The first two VGPRs are used for i/j barycentric coordinates. In the vast majority of
58+
// cases it will be only those two, but if shader is using both e.g linear and perspective
59+
// inputs it can be more For now assume that this isn't the case.
60+
dst_vreg = IR::VectorReg::V2;
61+
for (u32 i = 0; i < 4; i++) {
62+
ir.SetVectorReg(dst_vreg++, ir.GetAttribute(IR::Attribute::FragCoord, i));
12363
}
64+
ir.SetVectorReg(dst_vreg++, ir.GetAttributeU32(IR::Attribute::IsFrontFace));
12465
break;
12566
case Stage::Compute:
12667
ir.SetVectorReg(dst_vreg++, ir.GetAttributeU32(IR::Attribute::LocalInvocationId, 0));

src/shader_recompiler/runtime_info.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include <span>
88
#include <boost/container/static_vector.hpp>
99
#include "common/types.h"
10-
#include "video_core/amdgpu/liverpool.h"
1110
#include "video_core/amdgpu/types.h"
1211

1312
namespace Shader {
@@ -106,8 +105,6 @@ struct FragmentRuntimeInfo {
106105

107106
auto operator<=>(const PsInput&) const noexcept = default;
108107
};
109-
AmdGpu::Liverpool::PsInput en_flags;
110-
AmdGpu::Liverpool::PsInput addr_flags;
111108
u32 num_inputs;
112109
std::array<PsInput, 32> inputs;
113110
struct PsColorBuffer {
@@ -120,7 +117,6 @@ struct FragmentRuntimeInfo {
120117

121118
bool operator==(const FragmentRuntimeInfo& other) const noexcept {
122119
return std::ranges::equal(color_buffers, other.color_buffers) &&
123-
en_flags.raw == other.en_flags.raw && addr_flags.raw == other.addr_flags.raw &&
124120
num_inputs == other.num_inputs &&
125121
std::ranges::equal(inputs.begin(), inputs.begin() + num_inputs, other.inputs.begin(),
126122
other.inputs.begin() + num_inputs);

src/video_core/amdgpu/liverpool.h

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,28 +1071,6 @@ struct Liverpool {
10711071
BitField<27, 1, u32> enable_postz_overrasterization;
10721072
};
10731073

1074-
union PsInput {
1075-
u32 raw;
1076-
struct {
1077-
u32 persp_sample_ena : 1;
1078-
u32 persp_center_ena : 1;
1079-
u32 persp_centroid_ena : 1;
1080-
u32 persp_pull_model_ena : 1;
1081-
u32 linear_sample_ena : 1;
1082-
u32 linear_center_ena : 1;
1083-
u32 linear_centroid_ena : 1;
1084-
u32 line_stipple_tex_ena : 1;
1085-
u32 pos_x_float_ena : 1;
1086-
u32 pos_y_float_ena : 1;
1087-
u32 pos_z_float_ena : 1;
1088-
u32 pos_w_float_ena : 1;
1089-
u32 front_face_ena : 1;
1090-
u32 ancillary_ena : 1;
1091-
u32 sample_coverage_ena : 1;
1092-
u32 pos_fixed_pt_ena : 1;
1093-
};
1094-
};
1095-
10961074
union Regs {
10971075
struct {
10981076
INSERT_PADDING_WORDS(0x2C08);
@@ -1148,10 +1126,7 @@ struct Liverpool {
11481126
INSERT_PADDING_WORDS(0xA191 - 0xA187);
11491127
std::array<PsInputControl, 32> ps_inputs;
11501128
VsOutputConfig vs_output_config;
1151-
INSERT_PADDING_WORDS(1);
1152-
PsInput ps_input_ena;
1153-
PsInput ps_input_addr;
1154-
INSERT_PADDING_WORDS(1);
1129+
INSERT_PADDING_WORDS(4);
11551130
BitField<0, 6, u32> num_interp;
11561131
INSERT_PADDING_WORDS(0xA1C3 - 0xA1B6 - 1);
11571132
ShaderPosFormat shader_pos_format;
@@ -1413,8 +1388,6 @@ static_assert(GFX6_3D_REG_INDEX(viewports) == 0xA10F);
14131388
static_assert(GFX6_3D_REG_INDEX(clip_user_data) == 0xA16F);
14141389
static_assert(GFX6_3D_REG_INDEX(ps_inputs) == 0xA191);
14151390
static_assert(GFX6_3D_REG_INDEX(vs_output_config) == 0xA1B1);
1416-
static_assert(GFX6_3D_REG_INDEX(ps_input_ena) == 0xA1B3);
1417-
static_assert(GFX6_3D_REG_INDEX(ps_input_addr) == 0xA1B4);
14181391
static_assert(GFX6_3D_REG_INDEX(num_interp) == 0xA1B6);
14191392
static_assert(GFX6_3D_REG_INDEX(shader_pos_format) == 0xA1C3);
14201393
static_assert(GFX6_3D_REG_INDEX(z_export_format) == 0xA1C4);

src/video_core/renderer_vulkan/vk_pipeline_cache.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,6 @@ Shader::RuntimeInfo PipelineCache::BuildRuntimeInfo(Shader::Stage stage) {
123123
}
124124
case Shader::Stage::Fragment: {
125125
BuildCommon(regs.ps_program);
126-
info.fs_info.en_flags = regs.ps_input_ena;
127-
info.fs_info.addr_flags = regs.ps_input_addr;
128126
const auto& ps_inputs = regs.ps_inputs;
129127
info.fs_info.num_inputs = regs.num_interp;
130128
for (u32 i = 0; i < regs.num_interp; i++) {

0 commit comments

Comments
 (0)