moduleCreateInfo.pCode = code;
moduleCreateInfo.flags = 0;
err = vkCreateShaderModule(demo->device, &moduleCreateInfo, pShaderModule);
- if (err) {
- free((void *) moduleCreateInfo.pCode);
- }
+ assert(!err);
shaderCreateInfo.flags = 0;
shaderCreateInfo.module = *pShaderModule;
memcpy(((uint32_t *) moduleCreateInfo.pCode + 3), code, size + 1);
err = vkCreateShaderModule(demo->device, &moduleCreateInfo, pShaderModule);
- if (err) {
- free((void *) moduleCreateInfo.pCode);
- }
+ assert(!err);
shaderCreateInfo.flags = 0;
shaderCreateInfo.module = *pShaderModule;
shaderCreateInfo.stage = stage;
err = vkCreateShader(demo->device, &shaderCreateInfo, &shader);
assert(!err);
+ free((void *) moduleCreateInfo.pCode);
}
return shader;
}
static VkShader demo_prepare_vs(struct demo *demo)
{
if (!demo->use_glsl) {
- void *vertShaderCode;
- size_t size;
+ VkShader shader;
+ void *vertShaderCode;
+ size_t size;
- vertShaderCode = demo_read_spv("tri-vert.spv", &size);
+ vertShaderCode = demo_read_spv("tri-vert.spv", &size);
- return demo_prepare_shader(demo, VK_SHADER_STAGE_VERTEX,
- &demo->vert_shader_module,
- vertShaderCode, size);
+ shader = demo_prepare_shader(demo, VK_SHADER_STAGE_VERTEX,
+ &demo->vert_shader_module,
+ vertShaderCode, size);
+ free(vertShaderCode);
+ return shader;
} else {
static const char *vertShaderText =
"#version 140\n"
static VkShader demo_prepare_fs(struct demo *demo)
{
if (!demo->use_glsl) {
- void *fragShaderCode;
- size_t size;
+ VkShader shader;
+ void *fragShaderCode;
+ size_t size;
+
+ fragShaderCode = demo_read_spv("tri-frag.spv", &size);
- fragShaderCode = demo_read_spv("tri-frag.spv", &size);
+ shader = demo_prepare_shader(demo, VK_SHADER_STAGE_FRAGMENT,
+ &demo->frag_shader_module,
+ fragShaderCode, size);
- return demo_prepare_shader(demo, VK_SHADER_STAGE_FRAGMENT,
- &demo->frag_shader_module,
- fragShaderCode, size);
+ free(fragShaderCode);
+ return shader;
} else {
static const char *fragShaderText =
"#version 140\n"
vkDestroyDevice(demo->device);
vkDestroyInstance(demo->inst);
+ free(demo->queue_props);
+
#ifndef _WIN32
xcb_destroy_window(demo->connection, demo->window);
xcb_disconnect(demo->connection);
+ free(demo->atom_wm_delete_window);
#endif // _WIN32
}