Vulkan fixes
This commit is contained in:
@@ -376,7 +376,8 @@ function make_mesh_run(data: material_t, layer_pass: i32 = 0): node_shader_conte
|
||||
kong.frag_vvec = true;
|
||||
node_shader_write_frag(kong, "var dotnv: float = max(0.0, dot(n, vvec));");
|
||||
// node_shader_write_frag(kong, "var env_brdf: float2 = senvmap_brdf[uint2(float2(roughness, 1.0 - dotnv) * 256.0)].xy;");
|
||||
node_shader_write_frag(kong, "var env_brdf: float4 = senvmap_brdf[uint2(float2(roughness, 1.0 - dotnv) * 256.0)];");
|
||||
node_shader_write_frag(kong, "var brdf_coord: float2 = float2(roughness, 1.0 - dotnv) * 256.0;");
|
||||
node_shader_write_frag(kong, "var env_brdf: float4 = senvmap_brdf[uint2(uint(brdf_coord.x), uint(brdf_coord.y))];");
|
||||
// node_shader_add_constant(kong, "envmap_num_mipmaps: int", "_envmap_num_mipmaps");
|
||||
node_shader_add_constant(kong, "envmap_data: float4", "_envmap_data"); // angle, sin(angle), cos(angle), strength
|
||||
node_shader_write_frag(kong, "var wreflect: float3 = reflect(-vvec, n);");
|
||||
@@ -405,8 +406,8 @@ function make_mesh_run(data: material_t, layer_pass: i32 = 0): node_shader_conte
|
||||
node_shader_add_constant(kong, "shirr6: float4", "_envmap_irradiance6");
|
||||
node_shader_add_function(kong, str_sh_irradiance);
|
||||
node_shader_write_frag(kong, "var indirect: float3 = albedo * (sh_irradiance(float3(n.x * constants.envmap_data.z - n.y * constants.envmap_data.y, n.x * constants.envmap_data.y + n.y * constants.envmap_data.z, n.z)) / 3.14159265);");
|
||||
node_shader_write_frag(kong, "indirect += prefiltered_color * (f0 * env_brdf.x + env_brdf.y) * 1.5;");
|
||||
node_shader_write_frag(kong, "indirect *= constants.envmap_data.w * occlusion;");
|
||||
node_shader_write_frag(kong, "indirect = indirect + (prefiltered_color * (f0 * env_brdf.x + env_brdf.y) * 1.5);");
|
||||
node_shader_write_frag(kong, "indirect = indirect * constants.envmap_data.w * occlusion;");
|
||||
node_shader_write_frag(kong, "output[1] = float4(indirect, 1.0);");
|
||||
}
|
||||
else { // Deferred, Pathtraced
|
||||
@@ -458,7 +459,10 @@ function make_mesh_run(data: material_t, layer_pass: i32 = 0): node_shader_conte
|
||||
let id: i32 = context_raw.layer.id;
|
||||
node_shader_add_texture(kong, "texpaint_nor" + id);
|
||||
node_shader_add_constant(kong, "texpaint_size: float2", "_texpaint_size");
|
||||
node_shader_write_frag(kong, "var sample_matid: float = texpaint_nor" + id + "[uint2(input.tex_coord * constants.texpaint_size)].a + 1.0 / 255.0;");
|
||||
// node_shader_write_frag(kong, "var sample_matid: float = texpaint_nor" + id + "[uint2(input.tex_coord * constants.texpaint_size)].a + 1.0 / 255.0;");
|
||||
node_shader_write_frag(kong, "var sample_matid_coord: float2 = input.tex_coord * constants.texpaint_size;");
|
||||
node_shader_write_frag(kong, "var sample_matid4: float4 = texpaint_nor" + id + "[uint2(uint(sample_matid_coord.x), uint(sample_matid_coord.y))];");
|
||||
node_shader_write_frag(kong, "var sample_matid: float = sample_matid4.a + 1.0 / 255.0;");
|
||||
node_shader_write_frag(kong, "var matid_r: float = frac(sin(dot(float2(sample_matid, sample_matid * 20.0), float2(12.9898, 78.233))) * 43758.5453);");
|
||||
node_shader_write_frag(kong, "var matid_g: float = frac(sin(dot(float2(sample_matid * 20.0, sample_matid), float2(12.9898, 78.233))) * 43758.5453);");
|
||||
node_shader_write_frag(kong, "var matid_b: float = frac(sin(dot(float2(sample_matid, sample_matid * 40.0), float2(12.9898, 78.233))) * 43758.5453);");
|
||||
|
||||
@@ -3074,7 +3074,7 @@ void gpu_raytrace_set_target(gpu_texture_t *_output) {
|
||||
if (_output != output) {
|
||||
vkDestroyImage(device, _output->impl.image, NULL);
|
||||
|
||||
VkImageCreateInfo image = {
|
||||
VkImageCreateInfo image_info = {
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
|
||||
.pNext = NULL,
|
||||
.imageType = VK_IMAGE_TYPE_2D,
|
||||
@@ -3089,12 +3089,10 @@ void gpu_raytrace_set_target(gpu_texture_t *_output) {
|
||||
.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_STORAGE_BIT,
|
||||
.flags = 0,
|
||||
};
|
||||
|
||||
vkCreateImage(device, &image, NULL, &_output->impl.image);
|
||||
|
||||
vkCreateImage(device, &image_info, NULL, &_output->impl.image);
|
||||
vkBindImageMemory(device, _output->impl.image, _output->impl.mem, 0);
|
||||
|
||||
VkImageViewCreateInfo color_image_view = {
|
||||
VkImageViewCreateInfo image_view_info = {
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
|
||||
.pNext = NULL,
|
||||
.viewType = VK_IMAGE_VIEW_TYPE_2D,
|
||||
@@ -3107,7 +3105,9 @@ void gpu_raytrace_set_target(gpu_texture_t *_output) {
|
||||
.subresourceRange.layerCount = 1,
|
||||
.image = _output->impl.image,
|
||||
};
|
||||
vkCreateImageView(device, &color_image_view, NULL, &_output->impl.view);
|
||||
vkCreateImageView(device, &image_view_info, NULL, &_output->impl.view);
|
||||
|
||||
set_image_layout(_output->impl.image, VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
|
||||
}
|
||||
output = _output;
|
||||
}
|
||||
@@ -3130,7 +3130,7 @@ void gpu_raytrace_dispatch_rays() {
|
||||
|
||||
VkDescriptorImageInfo image_descriptor = {
|
||||
.imageView = output->impl.view,
|
||||
.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
|
||||
.imageLayout = VK_IMAGE_LAYOUT_GENERAL,
|
||||
};
|
||||
|
||||
VkDescriptorBufferInfo buffer_descriptor = {
|
||||
@@ -3312,6 +3312,8 @@ void gpu_raytrace_dispatch_rays() {
|
||||
};
|
||||
vkUpdateDescriptorSets(device, 12, write_descriptor_sets, 0, VK_NULL_HANDLE);
|
||||
|
||||
set_image_layout(output->impl.image, VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, VK_IMAGE_LAYOUT_GENERAL);
|
||||
|
||||
VkPhysicalDeviceRayTracingPipelinePropertiesKHR ray_tracing_pipeline_properties;
|
||||
ray_tracing_pipeline_properties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_PIPELINE_PROPERTIES_KHR;
|
||||
ray_tracing_pipeline_properties.pNext = NULL;
|
||||
@@ -3354,4 +3356,6 @@ void gpu_raytrace_dispatch_rays() {
|
||||
_vkCmdTraceRaysKHR = (void *)vkGetDeviceProcAddr(device, "vkCmdTraceRaysKHR");
|
||||
_vkCmdTraceRaysKHR(command_buffer, &raygen_shader_sbt_entry, &miss_shader_sbt_entry, &hit_shader_sbt_entry, &callable_shader_sbt_entry,
|
||||
output->width, output->height, 1);
|
||||
|
||||
set_image_layout(output->impl.image, VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_GENERAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
|
||||
}
|
||||
|
||||
@@ -307,7 +307,9 @@ static type_id find_access_type(int *indices, access_kind *access_kinds, int ind
|
||||
return find_access_type(&indices[1], &access_kinds[1], indices_size - 1, t->base);
|
||||
}
|
||||
case ACCESS_SWIZZLE:
|
||||
assert(false);
|
||||
////
|
||||
// assert(false);
|
||||
////
|
||||
return base_type;
|
||||
case ACCESS_MEMBER: {
|
||||
type *t = get_type(base_type);
|
||||
|
||||
+10
-10
@@ -336,16 +336,16 @@ fun sh_irradiance(nor: float3): float3 { \
|
||||
var cl21: float3 = float3(constants.shirr5.y, constants.shirr5.z, constants.shirr5.w); \
|
||||
var cl22: float3 = float3(constants.shirr6.x, constants.shirr6.y, constants.shirr6.z); \
|
||||
return ( \
|
||||
c1 * cl22 * (nor.y * nor.y - (-nor.z) * (-nor.z)) + \
|
||||
c3 * cl20 * nor.x * nor.x + \
|
||||
c4 * cl00 - \
|
||||
c5 * cl20 + \
|
||||
2.0 * c1 * cl2m2 * nor.y * (-nor.z) + \
|
||||
2.0 * c1 * cl21 * nor.y * nor.x + \
|
||||
2.0 * c1 * cl2m1 * (-nor.z) * nor.x + \
|
||||
2.0 * c2 * cl11 * nor.y + \
|
||||
2.0 * c2 * cl1m1 * (-nor.z) + \
|
||||
2.0 * c2 * cl10 * nor.x \
|
||||
cl22 * c1 * (nor.y * nor.y - (-nor.z) * (-nor.z)) + \
|
||||
cl20 * c3 * nor.x * nor.x + \
|
||||
cl00 * c4 - \
|
||||
cl20 * c5 + \
|
||||
cl2m2 * 2.0 * c1 * nor.y * (-nor.z) + \
|
||||
cl21 * 2.0 * c1 * nor.y * nor.x + \
|
||||
cl2m1 * 2.0 * c1 * (-nor.z) * nor.x + \
|
||||
cl11 * 2.0 * c2 * nor.y + \
|
||||
cl1m1 * 2.0 * c2 * (-nor.z) + \
|
||||
cl10 * 2.0 * c2 * nor.x \
|
||||
); \
|
||||
} \
|
||||
";
|
||||
|
||||
Reference in New Issue
Block a user