destroy();
}
-bool ShaderVK::load(const char *fname, SType type)
+bool ShaderVK::load(const char *fname, ShaderType type)
{
char *vk_fname = new char[strlen(fname) + strlen(".spirv") + 1];
strcpy(vk_fname, fname);
sminf.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
sminf.codeSize = bsz;
- sminf.pCode = (uint32_t*)buf;
+ sminf.pCode = (uint32_t *)buf;
- if(vkCreateShaderModule(vk_device, &sminf, 0, &sm) != VK_SUCCESS) {
+ if(vkCreateShaderModule(vk_device, &sminf, 0, &sdr) != VK_SUCCESS) {
delete [] buf;
fprintf(stderr, "Failed to create vertex shader module.\n");
void ShaderVK::destroy()
{
- vkDestroyShaderModule(vk_device, sm, 0);
+ vkDestroyShaderModule(vk_device, sdr, 0);
}
ShaderProgramVK::ShaderProgramVK()
ShaderProgramVK::~ShaderProgramVK()
{
+ destroy();
}
bool ShaderProgramVK::create()
{
- /* pipeline cache */
- VkPipelineCacheCreateInfo pcinf;
- memset(&pcinf, 0, sizeof pcinf);
- pcinf.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO;
-
- VkPipelineCache pcache;
- if(!vkCreatePipelineCache(vk_device, &pcinf, 0, &pcache) != VK_SUCCESS) {
- fprintf(stderr, "Failed to create pipeline cache.\n");
- return false;
- }
-
- /* pipeline */
- VkGraphicsPipelineCreateInfo gpinf;
- memset(&gpinf, 0, sizeof gpinf);
- gpinf.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
- gpinf.stageCount = 2;
-
- VkPipelineShaderStageCreateInfo ssinf[2];
- for(int i=0; i<2; i++) {
- memset(&ssinf[i], 0, sizeof ssinf[i]);
- ssinf[i].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
-
- switch(shaders[i]->get_type()) {
- case SDR_VERTEX:
- ssinf[i].stage = VK_SHADER_STAGE_VERTEX_BIT;
- break;
- case SDR_FRAGMENT:
- ssinf[i].stage = VK_SHADER_STAGE_FRAGMENT_BIT;
- break;
- default:
- fprintf(stderr, "Failed to create graphics pipeline: Invalid shader type.\n");
- return false;
- }
- ssinf[i].module = ((ShaderVK*)shaders[i])->sm;
- }
-
- gpinf.pStages = ssinf;
-
return true;
}
void ShaderProgramVK::destroy()
{
-}
-
-void ShaderProgramVK::attach_shader(Shader *shader)
-{
-}
-
-int ShaderProgramVK::get_uniform_location(const char *name) const
-{
- return 0;
-}
-
-void ShaderProgramVK::set_uniformi(int location, int value)
-{
-}
+ int len = sizeof shaders / sizeof *shaders;
-void ShaderProgramVK::set_uniformi(int location, int x, int y)
-{
-}
-
-void ShaderProgramVK::set_uniformi(int location, int x, int y, int z)
-{
-}
-
-void ShaderProgramVK::set_uniformi(int location, int x, int y, int z, int w)
-{
-}
-
-
-void ShaderProgramVK::set_uniformf(int location, float value)
-{
-}
-
-void ShaderProgramVK::set_uniformf(int location, float x, float y)
-{
-}
-
-void ShaderProgramVK::set_uniformf(int location, float x, float y, float z)
-{
-}
+ for(int i=0; i<len; ++i) {
+ delete shaders[i];
+ }
-void ShaderProgramVK::set_uniformf(int location, float x, float y, float z, float w)
-{
}
-void ShaderProgramVK::set_uniform_matrix(int location, const Mat4 &mat)
+void ShaderProgramVK::attach_shader(Shader *shader)
{
}