Merge pull request #505 from wheremyfoodat/moar-hle-dsp

GPU: Handle invalid floating point uniform writes
This commit is contained in:
wheremyfoodat 2024-05-01 21:51:02 +00:00 committed by GitHub
commit 70f443b06e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -256,14 +256,16 @@ class PICAShader {
void uploadFloatUniform(u32 word) {
floatUniformBuffer[floatUniformWordCount++] = word;
if (floatUniformIndex >= 96) {
Helpers::panic("[PICA] Tried to write float uniform %d", floatUniformIndex);
}
if ((f32UniformTransfer && floatUniformWordCount >= 4) || (!f32UniformTransfer && floatUniformWordCount >= 3)) {
vec4f& uniform = floatUniforms[floatUniformIndex++];
floatUniformWordCount = 0;
// Check if the program tries to upload to a non-existent uniform, and empty the queue without writing in that case
if (floatUniformIndex >= 96) [[unlikely]] {
return;
}
vec4f& uniform = floatUniforms[floatUniformIndex++];
if (f32UniformTransfer) {
uniform[0] = f24::fromFloat32(*(float*)&floatUniformBuffer[3]);
uniform[1] = f24::fromFloat32(*(float*)&floatUniformBuffer[2]);