comp: remove useless pano ubo from mesh distortion

It was left in as a debug measure, but is more confusing than useful,
especially with northstar directly generating a mesh and vive with its own shader.
This commit is contained in:
Christoph Haag 2020-09-16 02:15:35 +02:00
parent 3c0ae7e61e
commit e5683d4fde
3 changed files with 49 additions and 42 deletions

View file

@ -234,7 +234,9 @@ comp_distortion_destroy(struct comp_distortion *d)
vk->vkDestroyDescriptorSetLayout(vk->device, d->descriptor_set_layout, vk->vkDestroyDescriptorSetLayout(vk->device, d->descriptor_set_layout,
NULL); NULL);
_buffer_destroy(vk, &d->ubo_handle); if (d->has_fragment_shader_ubo) {
_buffer_destroy(vk, &d->ubo_handle);
}
_buffer_destroy(vk, &d->vbo_handle); _buffer_destroy(vk, &d->vbo_handle);
_buffer_destroy(vk, &d->index_handle); _buffer_destroy(vk, &d->index_handle);
_buffer_destroy(vk, &d->ubo_viewport_handles[0]); _buffer_destroy(vk, &d->ubo_viewport_handles[0]);
@ -512,19 +514,35 @@ comp_distortion_update_descriptor_set(struct comp_distortion *d,
.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, .imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
}; };
VkWriteDescriptorSet write_descriptor_sets[3] = { if (d->has_fragment_shader_ubo) {
// Binding 0 : Render texture target VkWriteDescriptorSet write_descriptor_sets[3] = {
comp_distortion_get_image_write_descriptor_set( // Binding 0 : Render texture target
d->descriptor_sets[eye], &image_info, 0), comp_distortion_get_image_write_descriptor_set(
// Binding 1 : Fragment shader uniform buffer d->descriptor_sets[eye], &image_info, 0),
comp_distortion_get_uniform_write_descriptor_set(d, 1, eye), // Binding 1 : Fragment shader uniform buffer
// Binding 2 : view uniform buffer comp_distortion_get_uniform_write_descriptor_set(d, 1, eye),
comp_distortion_get_uniform_write_descriptor_set_vp(d, 2, eye), // Binding 2 : view uniform buffer
}; comp_distortion_get_uniform_write_descriptor_set_vp(d, 2,
eye),
};
vk->vkUpdateDescriptorSets(vk->device, vk->vkUpdateDescriptorSets(vk->device,
ARRAY_SIZE(write_descriptor_sets), ARRAY_SIZE(write_descriptor_sets),
write_descriptor_sets, 0, NULL); write_descriptor_sets, 0, NULL);
} else {
VkWriteDescriptorSet write_descriptor_sets[2] = {
// Binding 0 : Render texture target
comp_distortion_get_image_write_descriptor_set(
d->descriptor_sets[eye], &image_info, 0),
// Binding 2 : view uniform buffer
comp_distortion_get_uniform_write_descriptor_set_vp(d, 2,
eye),
};
vk->vkUpdateDescriptorSets(vk->device,
ARRAY_SIZE(write_descriptor_sets),
write_descriptor_sets, 0, NULL);
}
d->ubo_vp_data[eye].flip_y = flip_y; d->ubo_vp_data[eye].flip_y = flip_y;
memcpy(d->ubo_viewport_handles[eye].mapped, &d->ubo_vp_data[eye], memcpy(d->ubo_viewport_handles[eye].mapped, &d->ubo_vp_data[eye],
@ -682,8 +700,9 @@ comp_distortion_update_uniform_buffer_warp(struct comp_distortion *d,
memcpy(d->ubo_handle.mapped, &d->ubo_vive, sizeof(d->ubo_vive)); memcpy(d->ubo_handle.mapped, &d->ubo_vive, sizeof(d->ubo_vive));
break; break;
case XRT_DISTORTION_MODEL_PANOTOOLS:
case XRT_DISTORTION_MODEL_MESHUV: case XRT_DISTORTION_MODEL_MESHUV:
break;
case XRT_DISTORTION_MODEL_PANOTOOLS:
default: default:
/* /*
* Pano vision fragment shader * Pano vision fragment shader
@ -836,12 +855,15 @@ comp_distortion_init_buffers(struct comp_distortion *d,
VkDeviceSize vbo_size = 0; VkDeviceSize vbo_size = 0;
VkDeviceSize index_size = 0; VkDeviceSize index_size = 0;
// overridden for mesh distortion in switch below
d->has_fragment_shader_ubo = true;
switch (d->distortion_model) { switch (d->distortion_model) {
case XRT_DISTORTION_MODEL_PANOTOOLS: case XRT_DISTORTION_MODEL_PANOTOOLS:
ubo_size = sizeof(d->ubo_pano); ubo_size = sizeof(d->ubo_pano);
break; break;
case XRT_DISTORTION_MODEL_MESHUV: case XRT_DISTORTION_MODEL_MESHUV:
ubo_size = sizeof(d->ubo_pano); d->has_fragment_shader_ubo = false;
vbo_size = d->mesh.stride * d->mesh.num_vertices; vbo_size = d->mesh.stride * d->mesh.num_vertices;
index_size = sizeof(int) * d->mesh.total_num_indices; index_size = sizeof(int) * d->mesh.total_num_indices;
break; break;
@ -855,15 +877,17 @@ comp_distortion_init_buffers(struct comp_distortion *d,
break; break;
} }
// fp ubo if (d->has_fragment_shader_ubo) {
ret = _create_buffer(vk, ubo_usage_flags, memory_property_flags, // fp ubo
&d->ubo_handle, ubo_size, NULL); ret = _create_buffer(vk, ubo_usage_flags, memory_property_flags,
if (ret != VK_SUCCESS) { &d->ubo_handle, ubo_size, NULL);
VK_DEBUG(vk, "Failed to create warp ubo buffer!"); if (ret != VK_SUCCESS) {
} VK_DEBUG(vk, "Failed to create warp ubo buffer!");
ret = _buffer_map(vk, &d->ubo_handle, VK_WHOLE_SIZE, 0); }
if (ret != VK_SUCCESS) { ret = _buffer_map(vk, &d->ubo_handle, VK_WHOLE_SIZE, 0);
VK_DEBUG(vk, "Failed to map warp ubo buffer!"); if (ret != VK_SUCCESS) {
VK_DEBUG(vk, "Failed to map warp ubo buffer!");
}
} }
// vp ubo[0] // vp ubo[0]

View file

@ -54,6 +54,7 @@ struct comp_distortion
// Holds all of the needed common Vulkan things. // Holds all of the needed common Vulkan things.
struct vk_bundle *vk; struct vk_bundle *vk;
bool has_fragment_shader_ubo;
struct comp_uniform_buffer ubo_handle; struct comp_uniform_buffer ubo_handle;
struct comp_uniform_buffer vbo_handle; struct comp_uniform_buffer vbo_handle;
struct comp_uniform_buffer index_handle; struct comp_uniform_buffer index_handle;

View file

@ -11,24 +11,6 @@
layout (binding = 0) uniform sampler2D tex_sampler; layout (binding = 0) uniform sampler2D tex_sampler;
layout (binding = 1, std140) uniform UBO
{
// Distoriton coefficients (PanoTools model) [a,b,c,d]
vec4 hmd_warp_param;
// chromatic distortion post scaling
vec4 aberr;
// Position of lens center in m (usually eye_w/2, eye_h/2)
vec2 lens_center[2];
// Scale from texture co-ords to m (usually eye_w, eye_h)
vec2 viewport_scale;
// Distortion overall scale in m (usually ~eye_w/2)
float warp_scale;
} ubo;
layout (location = 0) in vec2 in_ruv; layout (location = 0) in vec2 in_ruv;
layout (location = 1) in vec2 in_guv; layout (location = 1) in vec2 in_guv;
layout (location = 2) in vec2 in_buv; layout (location = 2) in vec2 in_buv;