Skip to content

Commit

Permalink
Fixed skybox push constants size to be less than 128 bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
corporateshark committed Dec 11, 2024
1 parent d8b7630 commit 594c736
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 13 deletions.
3 changes: 1 addition & 2 deletions Chapter08/02_SceneGraph/src/skybox.frag
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
//

layout(push_constant) uniform PerFrameData {
mat4 view;
mat4 proj;
mat4 mvp;
uint texSkybox;
} pc;

Expand Down
5 changes: 2 additions & 3 deletions Chapter08/02_SceneGraph/src/skybox.vert
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
//

layout(push_constant) uniform PerFrameData {
mat4 view;
mat4 proj;
mat4 mvp;
uint texSkybox;
} pc;

Expand Down Expand Up @@ -31,6 +30,6 @@ const int indices[36] = int[36](

void main() {
int idx = indices[gl_VertexIndex];
gl_Position = pc.proj * mat4(mat3(pc.view)) * vec4(1.0 * pos[idx], 1.0);
gl_Position = pc.mvp * vec4(1.0 * pos[idx], 1.0);
dir = pos[idx].xyz;
}
6 changes: 2 additions & 4 deletions Chapter08/03_LargeScene/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,10 @@ int main()
buf.cmdPushDebugGroupLabel("Skybox", 0xff0000ff);
buf.cmdBindRenderPipeline(pipelineSkybox);
const struct {
mat4 view;
mat4 proj;
mat4 mvp;
uint32_t texSkybox;
} pc = {
.view = view,
.proj = proj,
.mvp = proj * mat4(mat3(view)), // discard the translation
.texSkybox = texSkybox.index(),
};
buf.cmdPushConstants(pc);
Expand Down
6 changes: 2 additions & 4 deletions Chapter10/Skybox.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@ class Skybox
buf.cmdPushDebugGroupLabel("Skybox", 0xff0000ff);
buf.cmdBindRenderPipeline(pipelineSkybox);
const struct {
mat4 view;
mat4 proj;
mat4 mvp;
uint32_t texSkybox;
} pc = {
.view = view,
.proj = proj,
.mvp = proj * mat4(mat3(view)), // discard the translation
.texSkybox = texSkybox.index(),
};
buf.cmdPushConstants(pc);
Expand Down

0 comments on commit 594c736

Please sign in to comment.