feat: push constants + UBO descriptor sets — rotating triangle with VP matrix
- Push constants: rotation angle (float) sent to vertex shader via vkCmdPushConstants - UBO + descriptor sets: VP matrix (mat4) in uniform buffer, bound via VkDescriptorSet - New Vulkan functions: vkCreateDescriptorSetLayout, vkCreateDescriptorPool, vkAllocateDescriptorSets, vkUpdateDescriptorSets, vkCmdBindDescriptorSets, vkCmdPushConstants - New structs: VkPushConstantRange, VkDescriptorSetLayoutBinding, VkDescriptorSetLayoutCreateInfo, VkDescriptorPoolCreateInfo, VkDescriptorPoolSize, VkDescriptorSetAllocateInfo, VkWriteDescriptorSet, VkDescriptorBufferInfo - Per-frame UBO buffers (HOST_VISIBLE|HOST_COHERENT, 64 bytes each) - Perspective projection + look-at camera (static, no ECS yet) - Cleaned up debug logging in VulkanContext - Zero validation errors
This commit is contained in:
@@ -6,7 +6,22 @@ layout(location = 2) in vec3 inNormal;
|
||||
|
||||
layout(location = 0) out vec3 fragColor;
|
||||
|
||||
layout(row_major, set = 0, binding = 0) uniform CameraUBO {
|
||||
mat4 vp;
|
||||
};
|
||||
|
||||
layout(push_constant) uniform PC {
|
||||
float angle;
|
||||
} pc;
|
||||
|
||||
void main() {
|
||||
gl_Position = vec4(inPosition, 1.0);
|
||||
float c = cos(pc.angle);
|
||||
float s = sin(pc.angle);
|
||||
vec3 rotated = vec3(
|
||||
inPosition.x * c - inPosition.y * s,
|
||||
inPosition.x * s + inPosition.y * c,
|
||||
inPosition.z
|
||||
);
|
||||
gl_Position = vp * vec4(rotated, 1.0);
|
||||
fragColor = inColor;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user