Commit 37ea29b

gogu <ghglazar@gmail.com>
2026-03-28 21:43:07
changes
1 parent 9a4f739
libgogvk/gog_pipeline.c
@@ -1,5 +1,6 @@
 #include "gog_pipeline.h"
 #include <stdlib.h>
+#include <vulkan/vulkan_core.h>
 
 gog_result gog_create_pipeline_core(gog_pipeline_core * core, gog_pipeline_ci ci) {
 	core->vk_pipeline_device = ci.device;
@@ -51,11 +52,12 @@ gog_result gog_create_pipeline_core(gog_pipeline_core * core, gog_pipeline_ci ci
 		};
 
 		/* Setup Dynamic Rendering (Modern Vulkan style) */
-		VkPipelineRenderingCreateInfo dynamic_ci = {
+		VkPipelineRenderingCreateInfo dyn_render_ci = {
 			.sType = VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO,
+			.pNext = NULL,
 			.colorAttachmentCount = 1,
-			.pColorAttachmentFormats = &ci.graphics.canvas->color_format,
-			.depthAttachmentFormat = ci.graphics.canvas->depth_format
+			.pColorAttachmentFormats = &ci.graphics.canvas->format_i.color,
+			.depthAttachmentFormat = ci.graphics.canvas->format_i.depth
 		};
 
 		/* Fixed Function States from Atomic Raster/Canvas objects */
@@ -80,7 +82,7 @@ gog_result gog_create_pipeline_core(gog_pipeline_core * core, gog_pipeline_ci ci
 
 		VkPipelineMultisampleStateCreateInfo ms_ci = { 
 			.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO, 
-			.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT 
+			.rasterizationSamples = ci.graphics.canvas->format_i.samples 
 		};
 		
 		VkPipelineViewportStateCreateInfo vp_ci = { 
@@ -89,16 +91,15 @@ gog_result gog_create_pipeline_core(gog_pipeline_core * core, gog_pipeline_ci ci
 			.scissorCount = 1 
 		};
 
-		VkDynamicState dyn_states[] = { VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR };
-		VkPipelineDynamicStateCreateInfo dyn_ci = { 
+		VkPipelineDynamicStateCreateInfo dyn_state_ci = { 
 			.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO, 
-			.dynamicStateCount = 2, 
-			.pDynamicStates = dyn_states 
+			.dynamicStateCount = (uint32_t)ci.graphics.dynamic.count, 
+			.pDynamicStates = (VkDynamicState*)ci.graphics.dynamic.states 
 		};
 
 		VkGraphicsPipelineCreateInfo gfx_ci = {
 			.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO,
-			.pNext = &dynamic_ci,
+			.pNext = &dyn_render_ci,
 			.stageCount = ci.shader_c,
 			.pStages = stages,
 			.pVertexInputState = &v_input_ci,
@@ -107,7 +108,7 @@ gog_result gog_create_pipeline_core(gog_pipeline_core * core, gog_pipeline_ci ci
 			.pMultisampleState = &ms_ci,
 			.pDepthStencilState = &ds_ci,
 			.pViewportState = &vp_ci,
-			.pDynamicState = &dyn_ci,
+			.pDynamicState = &dyn_state_ci,
 			.layout = core->vk_pipeline_layout
 		};
 
libgogvk/gog_pipeline.h
@@ -45,34 +45,64 @@ typedef struct {
 } gog_vertex_buffer;
 
 typedef struct {
-	VkFormat color_format;
-	VkFormat depth_format;
-} gog_canvas_state;
+	VkImage color_img;
+	VkImageView color_view;
+	
+	VkImage depth_img;
+	VkImageView depth_view;
+	
+	struct {
+		VkFormat color;
+		VkFormat depth;
+		VkSampleCountFlagBits samples;
+		VkExtent2D extent; 
+	} format_i;
+} gog_canvas;
+
 
 typedef struct {
 	VkCullModeFlags cull_mode;
 	VkBool32 depth_test;
 } gog_raster_state;
 
+typedef enum {
+	GOG_MSAA_1 = VK_SAMPLE_COUNT_1_BIT,
+	GOG_MSAA_2 = VK_SAMPLE_COUNT_2_BIT,
+	GOG_MSAA_4 = VK_SAMPLE_COUNT_4_BIT,
+	GOG_MSAA_8 = VK_SAMPLE_COUNT_8_BIT
+} gog_msaa_level;
+
+typedef enum {
+	GOG_DYNAMIC_VIEWPORT = VK_DYNAMIC_STATE_VIEWPORT,
+	GOG_DYNAMIC_SCISSOR  = VK_DYNAMIC_STATE_SCISSOR,
+	GOG_DYNAMIC_LINE_WIDTH = VK_DYNAMIC_STATE_LINE_WIDTH,
+	GOG_DYNAMIC_DEPTH_BIAS = VK_DYNAMIC_STATE_DEPTH_BIAS
+} gog_dynamic_state_flag;
+
 typedef struct {
 	gog_pipeline_type type;
 	VkDevice device;
-
+	
 	gog_descriptor_set* descriptor_set; 
 	gog_push_constants* push_constants;
-
+	
 	uint32_t shader_c;
 	struct {
 		VkShaderModule mod;
 		VkShaderStageFlagBits stage;
 	} * shaders_p;
-
+	
 	union {
 		struct {
 			gog_vertex_buffer* v_buff;
-			gog_canvas_state* canvas;
+			gog_canvas* canvas;
 			gog_raster_state* raster;
+			struct {
+				gog_dynamic_state_flag* states;
+				size_t count;
+			} dynamic;
 		} graphics;
+			
 		struct {
 			size_t local_x, local_y, local_z;
 		} compute;
libgogvk.a
Binary file