Kaynağa Gözat

Vulkan fixes

luboslenco 4 ay önce
ebeveyn
işleme
7e43bceb27

+ 0 - 1
armorpaint/shaders/dilate_map.kong

@@ -7,7 +7,6 @@ struct vert_in {
 
 struct vert_out {
 	pos: float4;
-	dummy: float;
 }
 
 #[set(everything)]

+ 11 - 5
armorpaint/shaders/layer_merge.kong

@@ -59,11 +59,11 @@ fun layer_merge_frag(input: vert_out): float4 {
 	var str: float = col0.a * constants.opac;
 	str *= sample_lod(texmask, sampler_linear, input.tex, 0.0).r;
 
-	if (constants.blending == -1) { // Merging _nor and _pack
+	if (constants.blending == 101) { // Merging _nor and _pack
 		var col1: float4 = sample_lod(tex1, sampler_linear, input.tex, 0.0);
 		return float4(lerp4(cola, col1, str));
 	}
-	if (constants.blending == -2) { // Merging _nor with normal blending
+	if (constants.blending == 102) { // Merging _nor with normal blending
 		var col1: float4 = sample_lod(tex1, sampler_linear, input.tex, 0.0);
 		// Whiteout blend
 		var n1: float3 = cola.rgb * float3(2.0, 2.0, 2.0) - float3(1.0, 1.0, 1.0);
@@ -72,11 +72,11 @@ fun layer_merge_frag(input: vert_out): float4 {
 			normalize(float3(n1.xy + n2.xy, n1.z * n2.z)) * float3(0.5, 0.5, 0.5) + float3(0.5, 0.5, 0.5),
 			max(col1.a, cola.a));
 	}
-	if (constants.blending == -3) { // Merging _pack with height blending
+	if (constants.blending == 103) { // Merging _pack with height blending
 		var col1: float4 = sample_lod(tex1, sampler_linear, input.tex, 0.0);
 		return float4(lerp3(cola.rgb, col1.rgb, str), cola.a + col1.a);
 	}
-	if (constants.blending == -4) { // Merge _pack.height into _nor
+	if (constants.blending == 104) { // Merge _pack.height into _nor
 		var tex_step: float = 1.0 / constants.tex1w;
 		var height0: float = sample_lod(tex1, sampler_linear, float2(input.tex.x - tex_step, input.tex.y), 0.0).a;
 		var height1: float = sample_lod(tex1, sampler_linear, float2(input.tex.x + tex_step, input.tex.y), 0.0).a;
@@ -170,7 +170,12 @@ fun layer_merge_frag(input: vert_out): float4 {
 			(cola.rgb + str * (float3(2.0, 2.0, 2.0) * (col0.rgb - float3(0.5, 0.5, 0.5)))),
 			max(col0.a, cola.a));
 	}
-	if (constants.blending == 11) { // Difference
+
+
+
+	/* TODO: SPIRV
+
+	if (constants.blending == 11) {
 		return float4(
 			lerp3(cola.rgb, abs3(cola.rgb - col0.rgb), str),
 			max(col0.a, cola.a));
@@ -229,6 +234,7 @@ fun layer_merge_frag(input: vert_out): float4 {
 				str),
 			max(col0.a, cola.a));
 	}
+	*/
 
 	return float4(1, 1, 1, 1);
 }

+ 2 - 2
armorpaint/sources/layers_ext.ts

@@ -91,7 +91,7 @@ function layers_ext_flatten(height_to_normal: bool = false, layers: slot_layer_t
 			gpu_set_texture(pipes_texa, layers_temp_image);
 			gpu_set_float(pipes_opac, slot_layer_get_opacity(l1));
 			gpu_set_float(pipes_tex1w, l1.texpaint_nor.width);
-			gpu_set_int(pipes_blending, l1.paint_nor_blend ? -2 : -1);
+			gpu_set_int(pipes_blending, l1.paint_nor_blend ? 102 : 101);
 			gpu_set_vertex_buffer(const_data_screen_aligned_vb);
 			gpu_set_index_buffer(const_data_screen_aligned_ib);
 			gpu_draw();
@@ -155,7 +155,7 @@ function layers_ext_flatten(height_to_normal: bool = false, layers: slot_layer_t
 		gpu_set_texture(pipes_texa, empty);
 		gpu_set_float(pipes_opac, 1.0);
 		gpu_set_float(pipes_tex1w, l0.texpaint_pack.width);
-		gpu_set_int(pipes_blending, -4);
+		gpu_set_int(pipes_blending, 104);
 		gpu_set_vertex_buffer(const_data_screen_aligned_vb);
 		gpu_set_index_buffer(const_data_screen_aligned_ib);
 		gpu_draw();

+ 4 - 2
base/sources/iron.h

@@ -990,7 +990,7 @@ extern name_id names_index;
 extern size_t sets_count;
 extern type_id next_type_index;
 void hlsl_export2(char **vs, char **fs, api_kind d3d, bool debug);
-void spirv_export2(char **vs, char **fs, bool debug);
+void spirv_export2(char **vs, char **fs, int *vs_size, int *fs_size, bool debug);
 extern size_t vertex_inputs_size;
 extern size_t fragment_inputs_size;
 extern size_t vertex_functions_size;
@@ -1038,7 +1038,9 @@ void gpu_create_shaders_from_kong(char *kong, char **vs, char **fs) {
 	#else
 
 	transform(TRANSFORM_FLAG_ONE_COMPONENT_SWIZZLE | TRANSFORM_FLAG_BINARY_UNIFY_LENGTH);
-	spirv_export2(vs, fs, false);
+	int vs_size;
+	int fs_size;
+	spirv_export2(vs, fs, &vs_size, &fs_size, false);
 
 	#endif
 }

+ 1 - 1
base/sources/ts/export_texture.ts

@@ -274,7 +274,7 @@ function export_texture_run_layers(path: string, layers: slot_layer_t[], object_
 			gpu_set_texture(pipes_texa, layers_temp_image);
 			gpu_set_float(pipes_opac, slot_layer_get_opacity(l1));
 			gpu_set_float(pipes_tex1w, l1.texpaint_nor.width);
-			gpu_set_int(pipes_blending, l1.paint_nor_blend ? -2 : -1);
+			gpu_set_int(pipes_blending, l1.paint_nor_blend ? 102 : 101);
 			gpu_set_vertex_buffer(const_data_screen_aligned_vb);
 			gpu_set_index_buffer(const_data_screen_aligned_ib);
 			gpu_draw();

+ 1 - 1
base/sources/ts/layers.ts

@@ -775,7 +775,7 @@ function layers_merge_layer(l0 : slot_layer_t, l1: slot_layer_t, use_mask: bool
 				gpu_set_texture(pipes_texa, layers_temp_image);
 				gpu_set_float(pipes_opac, slot_layer_get_opacity(l1));
 				gpu_set_float(pipes_tex1w, l1.texpaint_nor.width);
-				gpu_set_int(pipes_blending, l1.paint_nor_blend ? -2 : -1);
+				gpu_set_int(pipes_blending, l1.paint_nor_blend ? 102 : 101);
 				gpu_set_vertex_buffer(const_data_screen_aligned_vb);
 				gpu_set_index_buffer(const_data_screen_aligned_ib);
 				gpu_draw();

+ 21 - 2
base/tools/amake/ashader.c

@@ -64,7 +64,7 @@ extern name_id names_index;
 extern size_t sets_count;
 extern type_id next_type_index;
 void hlsl_export2(char **vs, char **fs, api_kind d3d, bool debug);
-void spirv_export2(char **vs, char **fs, bool debug);
+void spirv_export2(char **vs, char **fs, int *vs_size, int *fs_size, bool debug);
 extern size_t vertex_inputs_size;
 extern size_t fragment_inputs_size;
 extern size_t vertex_functions_size;
@@ -185,7 +185,26 @@ void kong_compile(const char *from, const char *to) {
 	transform(TRANSFORM_FLAG_ONE_COMPONENT_SWIZZLE | TRANSFORM_FLAG_BINARY_UNIFY_LENGTH);
 	char *vs;
 	char *fs;
-	spirv_export2(&vs, &fs, false);
+	int vs_size;
+	int fs_size;
+	spirv_export2(&vs, &fs, &vs_size, &fs_size, false);
+
+	char to_[512];
+	strcpy(to_, to);
+	to_[strlen(to_) - 5] = '\0';
+	strcat(to_, "vert.spirv");
+
+	fp = fopen(to_, "wb");
+	fwrite(vs, 1, vs_size, fp);
+	fclose(fp);
+
+	strcpy(to_, to);
+	to_[strlen(to_) - 5] = '\0';
+	strcat(to_, "frag.spirv");
+
+	fp = fopen(to_, "wb");
+	fwrite(fs, 1, fs_size, fp);
+	fclose(fp);
 
 	#endif
 }