--- /dev/null
+#version 450
+#extension GL_ARB_separate_shader_objects : enable
+
+layout(location = 0) in vec3 incol;
+layout(location = 0) out vec4 outcol;
+
+void main()
+{
+ outcol = vec4(incol, 1.0);
+}
--- /dev/null
+#version 450
+#extension GL_ARB_separate_shader_objects : enable
+
+out gl_PerVertex {
+ vec4 gl_Position;
+};
+
+layout(location = 0) out vec3 color;
+
+vec2 vpos[3] = vec2[](
+ vec2(0.0, -0.5),
+ vec2(0.5, 0.5),
+ vec2(-0.5, 0.5)
+);
+
+vec3 vcol[3] = vec3[](
+ vec3(1.0, 0.0, 0.0),
+ vec3(0.0, 1.0, 0.0),
+ vec3(0.0, 0.0, 1.0)
+);
+
+void main()
+{
+ gl_Position = vec4(vpos[gl_VertexIndex], 0.0, 1.0);
+ color = vcol[gl_VertexIndex];
+}
static struct frame frame[NUM_FRM];
static VkSemaphore sem_draw;
static VkQueue queue;
+static VkShaderModule vsdr, psdr;
int app_init(void)
{
vk_pipeln_rpass(pipeln, vk_rpass(rpass));
vk_pipeln_viewport(pipeln, 0, 0, win_width, win_height);
+ if(!(vsdr = vk_load_shader("sdr/sdr.v.spv")) || !(psdr = vk_load_shader("sdr/sdr.p.spv"))) {
+ fprintf(stderr, "failed to load shaders\n");
+ return -1;
+ }
+ vk_pipeln_shader(pipeln, VKSDR_VERTEX, vsdr);
+ vk_pipeln_shader(pipeln, VKSDR_PIXEL, psdr);
+
sem_draw = vk_create_sem();
return 0;
}
}
vk_free_rpass(rpass);
+ vk_free_shader(vsdr);
+ vk_free_shader(psdr);
+
for(i=0; i<NUM_FRM; i++) {
vk_free_fence(frame[i].imgfence);
vk_free_sem(frame[i].sem_getimg);
rpbegin.clearValueCount = 1;
vkCmdBeginRenderPass(cmdbuf, &rpbegin, VK_SUBPASS_CONTENTS_INLINE);
-
- /* ... */
-
+ vkCmdBindPipeline(cmdbuf, VK_PIPELINE_BIND_POINT_GRAPHICS, vk_pipeln(pipeln));
+ vkCmdDraw(cmdbuf, 3, 1, 0, 0);
vkCmdEndRenderPass(cmdbuf);
vkEndCommandBuffer(cmdbuf);
}
}
}
+ if(pipelines) {
+ for(i=0; i<darr_size(pipelines); i++) {
+ if(pipelines[i].used) {
+ vk_free_pipeln(i);
+ }
+ }
+ }
+
if(vkdev) {
vkDestroyDevice(vkdev, 0);
vkdev = 0;
if(!pipelines || pp < 1 || pp >= darr_size(pipelines)) {
return;
}
+ if(!pipelines[pp].used) {
+ return;
+ }
+
+ if(pipelines[pp].vkobj_layout) {
+ vkDestroyPipelineLayout(vkdev, pipelines[pp].vkobj_layout, 0);
+ pipelines[pp].vkobj_layout = 0;
+ }
- if(pipelines[pp].used && pipelines[pp].vkobj) {
+ if(pipelines[pp].vkobj) {
vkDestroyPipeline(vkdev, pipelines[pp].vkobj, 0);
+ pipelines[pp].vkobj = 0;
}
pipelines[pp].used = 0;
}