Skip to content

Commit

Permalink
Optimize float uniform setting
Browse files Browse the repository at this point in the history
  • Loading branch information
wheremyfoodat committed May 1, 2024
1 parent 70f733f commit 8193242
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions include/PICA/shader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,16 +256,16 @@ class PICAShader {

void uploadFloatUniform(u32 word) {
floatUniformBuffer[floatUniformWordCount++] = word;
// 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)) {
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]);
Expand Down

0 comments on commit 8193242

Please sign in to comment.