Skip to content

Commit eb98319

Browse files
authored
Merge branch 'shadps4-emu:main' into new-readbacks-POC
2 parents 14f5469 + 91d2945 commit eb98319

File tree

16 files changed

+186
-39
lines changed

16 files changed

+186
-39
lines changed

.github/workflows/build.yml

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,13 @@ jobs:
7676
${{ env.cache-name }}-
7777
7878
- name: Cache CMake Build
79-
uses: hendrikmuhs/[email protected].17
79+
uses: hendrikmuhs/[email protected].18
8080
env:
8181
cache-name: ${{ runner.os }}-sdl-cache-cmake-build
8282
with:
8383
append-timestamp: false
8484
key: ${{ env.cache-name }}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }}
8585

86-
- name: Setup VS Environment
87-
uses: ilammy/[email protected]
88-
with:
89-
arch: amd64
90-
9186
- name: Configure CMake
9287
run: cmake --fresh -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE=ON -DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
9388

@@ -111,7 +106,7 @@ jobs:
111106
- name: Setup Qt
112107
uses: jurplel/install-qt-action@v4
113108
with:
114-
version: 6.9.0
109+
version: 6.9.1
115110
host: windows
116111
target: desktop
117112
arch: win64_msvc2022_64
@@ -130,18 +125,13 @@ jobs:
130125
${{ env.cache-name }}-
131126
132127
- name: Cache CMake Build
133-
uses: hendrikmuhs/[email protected].17
128+
uses: hendrikmuhs/[email protected].18
134129
env:
135130
cache-name: ${{ runner.os }}-qt-cache-cmake-build
136131
with:
137132
append-timestamp: false
138133
key: ${{ env.cache-name }}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }}
139134

140-
- name: Setup VS Environment
141-
uses: ilammy/[email protected]
142-
with:
143-
arch: amd64
144-
145135
- name: Configure CMake
146136
run: cmake --fresh -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DENABLE_QT_GUI=ON -DENABLE_UPDATER=ON -DCMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE=ON -DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
147137

@@ -186,7 +176,7 @@ jobs:
186176
${{ env.cache-name }}-
187177
188178
- name: Cache CMake Build
189-
uses: hendrikmuhs/[email protected].17
179+
uses: hendrikmuhs/[email protected].18
190180
env:
191181
cache-name: ${{runner.os}}-sdl-cache-cmake-build
192182
with:
@@ -228,7 +218,7 @@ jobs:
228218
- name: Setup Qt
229219
uses: jurplel/install-qt-action@v4
230220
with:
231-
version: 6.9.0
221+
version: 6.9.1
232222
host: mac
233223
target: desktop
234224
arch: clang_64
@@ -247,7 +237,7 @@ jobs:
247237
${{ env.cache-name }}-
248238
249239
- name: Cache CMake Build
250-
uses: hendrikmuhs/[email protected].17
240+
uses: hendrikmuhs/[email protected].18
251241
env:
252242
cache-name: ${{runner.os}}-qt-cache-cmake-build
253243
with:
@@ -301,7 +291,7 @@ jobs:
301291
${{ env.cache-name }}-
302292
303293
- name: Cache CMake Build
304-
uses: hendrikmuhs/[email protected].17
294+
uses: hendrikmuhs/[email protected].18
305295
env:
306296
cache-name: ${{ runner.os }}-sdl-cache-cmake-build
307297
with:
@@ -362,7 +352,7 @@ jobs:
362352
${{ env.cache-name }}-
363353
364354
- name: Cache CMake Build
365-
uses: hendrikmuhs/[email protected].17
355+
uses: hendrikmuhs/[email protected].18
366356
env:
367357
cache-name: ${{ runner.os }}-qt-cache-cmake-build
368358
with:
@@ -409,7 +399,7 @@ jobs:
409399
${{ env.cache-name }}-
410400
411401
- name: Cache CMake Build
412-
uses: hendrikmuhs/[email protected].17
402+
uses: hendrikmuhs/[email protected].18
413403
env:
414404
cache-name: ${{ runner.os }}-sdl-gcc-cache-cmake-build
415405
with:
@@ -445,7 +435,7 @@ jobs:
445435
${{ env.cache-name }}-
446436
447437
- name: Cache CMake Build
448-
uses: hendrikmuhs/[email protected].17
438+
uses: hendrikmuhs/[email protected].18
449439
env:
450440
cache-name: ${{ runner.os }}-qt-gcc-cache-cmake-build
451441
with:
@@ -494,7 +484,7 @@ jobs:
494484
with:
495485
token: ${{ secrets.SHADPS4_TOKEN_REPO }}
496486
name: "Pre-release-shadPS4-${{ needs.get-info.outputs.date }}-${{ needs.get-info.outputs.shorthash }}"
497-
tag: "Pre-release-shadPS4-${{ needs.get-info.outputs.date }}-${{ needs.get-info.outputs.shorthash }}"
487+
tag: "Pre-release-shadPS4-${{ needs.get-info.outputs.date }}-${{ needs.get-info.outputs.fullhash }}"
498488
draft: false
499489
prerelease: true
500490
body: "Full Changelog: [${{ env.last_release_tag }}...${{ needs.get-info.outputs.shorthash }}](https://github.com/shadps4-emu/shadPS4/compare/${{ env.last_release_tag }}...${{ needs.get-info.outputs.fullhash }})"
@@ -530,14 +520,14 @@ jobs:
530520
531521
# Check if release already exists and get ID
532522
release_id=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
533-
"https://api.github.com/repos/$REPO/releases/tags/Pre-release-shadPS4-${{ needs.get-info.outputs.date }}-${{ needs.get-info.outputs.shorthash }}" | jq -r '.id')
523+
"https://api.github.com/repos/$REPO/releases/tags/Pre-release-shadPS4-${{ needs.get-info.outputs.date }}-${{ needs.get-info.outputs.fullhash }}" | jq -r '.id')
534524
535525
if [[ "$release_id" == "null" ]]; then
536526
echo "Creating release in $REPO for $filename"
537527
release_id=$(curl -s -X POST -H "Authorization: token $GITHUB_TOKEN" \
538528
-H "Accept: application/vnd.github.v3+json" \
539529
-d '{
540-
"tag_name": "Pre-release-shadPS4-${{ needs.get-info.outputs.date }}-${{ needs.get-info.outputs.shorthash }}",
530+
"tag_name": "Pre-release-shadPS4-${{ needs.get-info.outputs.date }}-${{ needs.get-info.outputs.fullhash }}",
541531
"name": "Pre-release-shadPS4-${{ needs.get-info.outputs.date }}-${{ needs.get-info.outputs.shorthash }}",
542532
"draft": false,
543533
"prerelease": true,

src/core/libraries/videoout/video_out.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,12 @@ s32 PS4_SYSV_ABI sceVideoOutGetVblankStatus(int handle, SceVideoOutVblankStatus*
282282

283283
s32 PS4_SYSV_ABI sceVideoOutGetResolutionStatus(s32 handle, SceVideoOutResolutionStatus* status) {
284284
LOG_INFO(Lib_VideoOut, "called");
285-
*status = driver->GetPort(handle)->resolution;
285+
auto* port = driver->GetPort(handle);
286+
if (!port || !port->is_open) {
287+
return ORBIS_VIDEO_OUT_ERROR_INVALID_HANDLE;
288+
}
289+
290+
*status = port->resolution;
286291
return ORBIS_OK;
287292
}
288293

src/core/libraries/zlib/zlib.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ void ZlibTaskThread(const std::stop_token& stop) {
5151
if (!task_queue_cv.wait(lock, stop, [&] { return !task_queue.empty(); })) {
5252
break;
5353
}
54-
task = task_queue.back();
54+
task = task_queue.front();
5555
task_queue.pop();
5656
}
5757

@@ -136,7 +136,7 @@ s32 PS4_SYSV_ABI sceZlibWaitForDone(u64* request_id, const u32* timeout) {
136136
} else {
137137
done_queue_cv.wait(lock, pred);
138138
}
139-
*request_id = done_queue.back();
139+
*request_id = done_queue.front();
140140
done_queue.pop();
141141
}
142142
return ORBIS_OK;

src/qt_gui/check_update.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ tr("The Auto Updater allows up to 60 update checks per hour.\\nYou have reached
137137
}
138138
}
139139

140-
latestRev = latestVersion.right(7);
140+
latestRev = latestVersion.right(40);
141141
latestDate = jsonObj["published_at"].toString();
142142

143143
QJsonArray assets = jsonObj["assets"].toArray();
@@ -167,7 +167,7 @@ tr("The Auto Updater allows up to 60 update checks per hour.\\nYou have reached
167167
QDateTime dateTime = QDateTime::fromString(latestDate, Qt::ISODate);
168168
latestDate = dateTime.isValid() ? dateTime.toString("yyyy-MM-dd HH:mm:ss") : "Unknown date";
169169

170-
if (latestRev == currentRev.left(7)) {
170+
if (latestRev == currentRev) {
171171
if (showMessage) {
172172
QMessageBox::information(this, tr("Auto Updater"),
173173
tr("Your version is already up to date!"));
@@ -215,7 +215,7 @@ void CheckUpdate::setupUI(const QString& downloadUrl, const QString& latestDate,
215215
"<td>%3</td>"
216216
"<td>(%4)</td>"
217217
"</tr></table></p>")
218-
.arg(currentRev.left(7), currentDate, latestRev, latestDate);
218+
.arg(currentRev.left(7), currentDate, latestRev.left(7), latestDate);
219219

220220
QLabel* updateLabel = new QLabel(updateText, this);
221221
layout->addWidget(updateLabel);

src/qt_gui/translations/pt_BR.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2048,7 +2048,7 @@
20482048
</message>
20492049
<message>
20502050
<source> * Unsupported Vulkan Version</source>
2051-
<translation type="unfinished"> * Unsupported Vulkan Version</translation>
2051+
<translation> * Versão do Vulkan não suportada</translation>
20522052
</message>
20532053
</context>
20542054
<context>

src/qt_gui/translations/tr_TR.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@
138138
</message>
139139
<message>
140140
<source>File Exists</source>
141-
<translation>Dosya mevcut</translation>
141+
<translation>Dosya Mevcut</translation>
142142
</message>
143143
<message>
144144
<source>File already exists. Do you want to replace it?</source>
@@ -1221,7 +1221,7 @@
12211221
</message>
12221222
<message>
12231223
<source>Exit shadPS4</source>
1224-
<translation>shadPS4&apos;ten Çık</translation>
1224+
<translation>shadPS4 Çıkış</translation>
12251225
</message>
12261226
<message>
12271227
<source>Exit the application.</source>
@@ -1381,7 +1381,7 @@
13811381
</message>
13821382
<message>
13831383
<source>Game Boot</source>
1384-
<translation>Oyun Başlatma</translation>
1384+
<translation>Oyun Başlat</translation>
13851385
</message>
13861386
<message>
13871387
<source>Only one file can be selected!</source>

src/shader_recompiler/backend/spirv/emit_spirv_instructions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ Id EmitBitCount64(EmitContext& ctx, Id value);
372372
Id EmitBitwiseNot32(EmitContext& ctx, Id value);
373373
Id EmitFindSMsb32(EmitContext& ctx, Id value);
374374
Id EmitFindUMsb32(EmitContext& ctx, Id value);
375+
Id EmitFindUMsb64(EmitContext& ctx, Id value);
375376
Id EmitFindILsb32(EmitContext& ctx, Id value);
376377
Id EmitFindILsb64(EmitContext& ctx, Id value);
377378
Id EmitSMin32(EmitContext& ctx, Id a, Id b);

src/shader_recompiler/backend/spirv/emit_spirv_integer.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,20 @@ Id EmitFindUMsb32(EmitContext& ctx, Id value) {
229229
return ctx.OpFindUMsb(ctx.U32[1], value);
230230
}
231231

232+
Id EmitFindUMsb64(EmitContext& ctx, Id value) {
233+
// Vulkan restricts some bitwise operations to 32-bit only, so decompose into
234+
// two 32-bit values and select the correct result.
235+
const Id unpacked{ctx.OpBitcast(ctx.U32[2], value)};
236+
const Id hi{ctx.OpCompositeExtract(ctx.U32[1], unpacked, 1U)};
237+
const Id lo{ctx.OpCompositeExtract(ctx.U32[1], unpacked, 0U)};
238+
const Id hi_msb{ctx.OpFindUMsb(ctx.U32[1], hi)};
239+
const Id lo_msb{ctx.OpFindUMsb(ctx.U32[1], lo)};
240+
const Id found_hi{ctx.OpINotEqual(ctx.U1[1], hi_msb, ctx.ConstU32(u32(-1)))};
241+
const Id shifted_hi{ctx.OpIAdd(ctx.U32[1], hi_msb, ctx.ConstU32(32u))};
242+
// value == 0 case is checked in IREmitter
243+
return ctx.OpSelect(ctx.U32[1], found_hi, shifted_hi, lo_msb);
244+
}
245+
232246
Id EmitFindILsb32(EmitContext& ctx, Id value) {
233247
return ctx.OpFindILsb(ctx.U32[1], value);
234248
}

src/shader_recompiler/frontend/translate/scalar_alu.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ void Translator::EmitScalarAlu(const GcnInst& inst) {
114114
return S_FF1_I32_B64(inst);
115115
case Opcode::S_FLBIT_I32_B32:
116116
return S_FLBIT_I32_B32(inst);
117+
case Opcode::S_FLBIT_I32_B64:
118+
return S_FLBIT_I32_B64(inst);
117119
case Opcode::S_BITSET0_B32:
118120
return S_BITSET_B32(inst, 0);
119121
case Opcode::S_BITSET1_B32:
@@ -686,6 +688,17 @@ void Translator::S_FLBIT_I32_B32(const GcnInst& inst) {
686688
SetDst(inst.dst[0], IR::U32{ir.Select(cond, pos_from_left, ir.Imm32(~0U))});
687689
}
688690

691+
void Translator::S_FLBIT_I32_B64(const GcnInst& inst) {
692+
const IR::U64 src0{GetSrc64(inst.src[0])};
693+
// Gcn wants the MSB position counting from the left, but SPIR-V counts from the rightmost (LSB)
694+
// position
695+
const IR::U32 msb_pos = ir.FindUMsb(src0);
696+
const IR::U32 pos_from_left = ir.ISub(ir.Imm32(63), msb_pos);
697+
// Select 0xFFFFFFFF if src0 was 0
698+
const IR::U1 cond = ir.INotEqual(src0, ir.Imm64(u64(0u)));
699+
SetDst(inst.dst[0], IR::U32{ir.Select(cond, pos_from_left, ir.Imm32(~0U))});
700+
}
701+
689702
void Translator::S_BITSET_B32(const GcnInst& inst, u32 bit_value) {
690703
const IR::U32 old_value{GetSrc(inst.dst[0])};
691704
const IR::U32 offset{ir.BitFieldExtract(GetSrc(inst.src[0]), ir.Imm32(0U), ir.Imm32(5U))};

src/shader_recompiler/frontend/translate/translate.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ class Translator {
121121
void S_FF1_I32_B32(const GcnInst& inst);
122122
void S_FF1_I32_B64(const GcnInst& inst);
123123
void S_FLBIT_I32_B32(const GcnInst& inst);
124+
void S_FLBIT_I32_B64(const GcnInst& inst);
124125
void S_BITSET_B32(const GcnInst& inst, u32 bit_value);
125126
void S_GETPC_B64(u32 pc, const GcnInst& inst);
126127
void S_SAVEEXEC_B64(NegateMode negate, bool is_or, const GcnInst& inst);
@@ -204,6 +205,7 @@ class Translator {
204205
void V_EXP_F32(const GcnInst& inst);
205206
void V_LOG_F32(const GcnInst& inst);
206207
void V_RCP_F32(const GcnInst& inst);
208+
void V_RCP_LEGACY_F32(const GcnInst& inst);
207209
void V_RCP_F64(const GcnInst& inst);
208210
void V_RSQ_F32(const GcnInst& inst);
209211
void V_SQRT_F32(const GcnInst& inst);

src/shader_recompiler/frontend/translate/vector_alu.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ void Translator::EmitVectorAlu(const GcnInst& inst) {
158158
return V_LOG_F32(inst);
159159
case Opcode::V_RCP_F32:
160160
return V_RCP_F32(inst);
161+
case Opcode::V_RCP_LEGACY_F32:
162+
return V_RCP_LEGACY_F32(inst);
161163
case Opcode::V_RCP_F64:
162164
return V_RCP_F64(inst);
163165
case Opcode::V_RCP_IFLAG_F32:
@@ -798,6 +800,20 @@ void Translator::V_RCP_F32(const GcnInst& inst) {
798800
SetDst(inst.dst[0], ir.FPRecip(src0));
799801
}
800802

803+
void Translator::V_RCP_LEGACY_F32(const GcnInst& inst) {
804+
const IR::F32 src0{GetSrc<IR::F32>(inst.src[0])};
805+
const auto result = ir.FPRecip(src0);
806+
const auto inf = ir.FPIsInf(result);
807+
808+
const auto raw_result = ir.ConvertFToU(32, result);
809+
const auto sign_bit = ir.ShiftRightLogical(raw_result, ir.Imm32(31u));
810+
const auto sign_bit_set = ir.INotEqual(sign_bit, ir.Imm32(0u));
811+
const IR::F32 inf_result{ir.Select(sign_bit_set, ir.Imm32(-0.0f), ir.Imm32(0.0f))};
812+
const IR::F32 val{ir.Select(inf, inf_result, result)};
813+
814+
SetDst(inst.dst[0], val);
815+
}
816+
801817
void Translator::V_RCP_F64(const GcnInst& inst) {
802818
const IR::F64 src0{GetSrc64<IR::F64>(inst.src[0])};
803819
SetDst64(inst.dst[0], ir.FPRecip(src0));

src/shader_recompiler/ir/ir_emitter.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1546,8 +1546,15 @@ U32 IREmitter::FindSMsb(const U32& value) {
15461546
return Inst<U32>(Opcode::FindSMsb32, value);
15471547
}
15481548

1549-
U32 IREmitter::FindUMsb(const U32& value) {
1550-
return Inst<U32>(Opcode::FindUMsb32, value);
1549+
U32 IREmitter::FindUMsb(const U32U64& value) {
1550+
switch (value.Type()) {
1551+
case Type::U32:
1552+
return Inst<U32>(Opcode::FindUMsb32, value);
1553+
case Type::U64:
1554+
return Inst<U32>(Opcode::FindUMsb64, value);
1555+
default:
1556+
ThrowInvalidType(value.Type());
1557+
}
15511558
}
15521559

15531560
U32 IREmitter::FindILsb(const U32U64& value) {

src/shader_recompiler/ir/ir_emitter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ class IREmitter {
266266
[[nodiscard]] U32 BitwiseNot(const U32& value);
267267

268268
[[nodiscard]] U32 FindSMsb(const U32& value);
269-
[[nodiscard]] U32 FindUMsb(const U32& value);
269+
[[nodiscard]] U32 FindUMsb(const U32U64& value);
270270
[[nodiscard]] U32 FindILsb(const U32U64& value);
271271
[[nodiscard]] U32 SMin(const U32& a, const U32& b);
272272
[[nodiscard]] U32 UMin(const U32& a, const U32& b);

src/shader_recompiler/ir/opcodes.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ OPCODE(BitwiseNot32, U32, U32,
349349

350350
OPCODE(FindSMsb32, U32, U32, )
351351
OPCODE(FindUMsb32, U32, U32, )
352+
OPCODE(FindUMsb64, U32, U64, )
352353
OPCODE(FindILsb32, U32, U32, )
353354
OPCODE(FindILsb64, U32, U64, )
354355
OPCODE(SMin32, U32, U32, U32, )

0 commit comments

Comments
 (0)