Skip to content

Commit

Permalink
GPU: Handle invalid floating point uniform writes
Browse files Browse the repository at this point in the history
  • Loading branch information
wheremyfoodat committed May 1, 2024
1 parent 6a424a7 commit 70f733f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions include/PICA/shader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,10 @@ class PICAShader {

void uploadFloatUniform(u32 word) {
floatUniformBuffer[floatUniformWordCount++] = word;
if (floatUniformIndex >= 96) {
Helpers::panic("[PICA] Tried to write float uniform %d", floatUniformIndex);
// 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]] {
floatUniformWordCount = 0;
return;
}

if ((f32UniformTransfer && floatUniformWordCount >= 4) || (!f32UniformTransfer && floatUniformWordCount >= 3)) {
Expand Down

0 comments on commit 70f733f

Please sign in to comment.