rt: deduplicate sbt spec copies into ray pass
This commit is contained in:
parent
9c679c39b8
commit
09b0e0f8ff
|
@ -60,6 +60,24 @@ struct ray_pass_s *RayPassCreateTracing( const ray_pass_create_tracing_t *create
|
|||
ray_pass_tracing_impl_t *const pass = Mem_Malloc(vk_core.pool, sizeof(*pass));
|
||||
ray_pass_t *const header = &pass->header;
|
||||
|
||||
// TODO support external specialization
|
||||
ASSERT(!create->specialization);
|
||||
|
||||
const struct SpecializationData {
|
||||
uint32_t sbt_record_size;
|
||||
} spec_data = {
|
||||
.sbt_record_size = vk_core.physical_device.sbt_record_size,
|
||||
};
|
||||
const VkSpecializationMapEntry spec_map[] = {
|
||||
{.constantID = SPEC_SBT_RECORD_SIZE_INDEX, .offset = offsetof(struct SpecializationData, sbt_record_size), .size = sizeof(uint32_t) },
|
||||
};
|
||||
const VkSpecializationInfo spec = {
|
||||
.mapEntryCount = COUNTOF(spec_map),
|
||||
.pMapEntries = spec_map,
|
||||
.dataSize = sizeof(spec_data),
|
||||
.pData = &spec_data,
|
||||
};
|
||||
|
||||
initPassDescriptors(header, &create->layout);
|
||||
|
||||
{
|
||||
|
@ -83,7 +101,7 @@ struct ray_pass_s *RayPassCreateTracing( const ray_pass_create_tracing_t *create
|
|||
stages[stage_index++] = (vk_shader_stage_t) {
|
||||
.filename = create->raygen,
|
||||
.stage = VK_SHADER_STAGE_RAYGEN_BIT_KHR,
|
||||
.specialization_info = create->specialization,
|
||||
.specialization_info = &spec,
|
||||
};
|
||||
|
||||
for (int i = 0; i < create->miss_count; ++i) {
|
||||
|
@ -98,7 +116,7 @@ struct ray_pass_s *RayPassCreateTracing( const ray_pass_create_tracing_t *create
|
|||
stages[stage_index++] = (vk_shader_stage_t) {
|
||||
.filename = *shader,
|
||||
.stage = VK_SHADER_STAGE_MISS_BIT_KHR,
|
||||
.specialization_info = create->specialization,
|
||||
.specialization_info = &spec,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -114,7 +132,7 @@ struct ray_pass_s *RayPassCreateTracing( const ray_pass_create_tracing_t *create
|
|||
stages[stage_index++] = (vk_shader_stage_t) {
|
||||
.filename = group->any,
|
||||
.stage = VK_SHADER_STAGE_ANY_HIT_BIT_KHR,
|
||||
.specialization_info = create->specialization,
|
||||
.specialization_info = &spec,
|
||||
};
|
||||
} else {
|
||||
hits[hit_index].any = -1;
|
||||
|
@ -126,7 +144,7 @@ struct ray_pass_s *RayPassCreateTracing( const ray_pass_create_tracing_t *create
|
|||
stages[stage_index++] = (vk_shader_stage_t) {
|
||||
.filename = group->closest,
|
||||
.stage = VK_SHADER_STAGE_CLOSEST_HIT_BIT_KHR,
|
||||
.specialization_info = create->specialization,
|
||||
.specialization_info = &spec,
|
||||
};
|
||||
} else {
|
||||
hits[hit_index].closest = -1;
|
||||
|
|
|
@ -58,22 +58,6 @@ static const int semantics_point[] = {
|
|||
};
|
||||
|
||||
struct ray_pass_s *R_VkRayLightDirectPolyPassCreate( void ) {
|
||||
// FIXME move this into vk_pipeline
|
||||
const struct SpecializationData {
|
||||
uint32_t sbt_record_size;
|
||||
} spec_data = {
|
||||
.sbt_record_size = vk_core.physical_device.sbt_record_size,
|
||||
};
|
||||
const VkSpecializationMapEntry spec_map[] = {
|
||||
{.constantID = SPEC_SBT_RECORD_SIZE_INDEX, .offset = offsetof(struct SpecializationData, sbt_record_size), .size = sizeof(uint32_t) },
|
||||
};
|
||||
VkSpecializationInfo spec = {
|
||||
.mapEntryCount = COUNTOF(spec_map),
|
||||
.pMapEntries = spec_map,
|
||||
.dataSize = sizeof(spec_data),
|
||||
.pData = &spec_data,
|
||||
};
|
||||
|
||||
const ray_pass_shader_t miss[] = {
|
||||
"ray_shadow.rmiss.spv"
|
||||
};
|
||||
|
@ -97,29 +81,13 @@ struct ray_pass_s *R_VkRayLightDirectPolyPassCreate( void ) {
|
|||
.miss_count = COUNTOF(miss),
|
||||
.hit = hit,
|
||||
.hit_count = COUNTOF(hit),
|
||||
.specialization = &spec,
|
||||
.specialization = NULL,
|
||||
};
|
||||
|
||||
return RayPassCreateTracing( &rpc );
|
||||
}
|
||||
|
||||
struct ray_pass_s *R_VkRayLightDirectPointPassCreate( void ) {
|
||||
// FIXME move this into vk_pipeline
|
||||
const struct SpecializationData {
|
||||
uint32_t sbt_record_size;
|
||||
} spec_data = {
|
||||
.sbt_record_size = vk_core.physical_device.sbt_record_size,
|
||||
};
|
||||
const VkSpecializationMapEntry spec_map[] = {
|
||||
{.constantID = SPEC_SBT_RECORD_SIZE_INDEX, .offset = offsetof(struct SpecializationData, sbt_record_size), .size = sizeof(uint32_t) },
|
||||
};
|
||||
VkSpecializationInfo spec = {
|
||||
.mapEntryCount = COUNTOF(spec_map),
|
||||
.pMapEntries = spec_map,
|
||||
.dataSize = sizeof(spec_data),
|
||||
.pData = &spec_data,
|
||||
};
|
||||
|
||||
const ray_pass_shader_t miss[] = {
|
||||
"ray_shadow.rmiss.spv"
|
||||
};
|
||||
|
@ -143,7 +111,7 @@ struct ray_pass_s *R_VkRayLightDirectPointPassCreate( void ) {
|
|||
.miss_count = COUNTOF(miss),
|
||||
.hit = hit,
|
||||
.hit_count = COUNTOF(hit),
|
||||
.specialization = &spec,
|
||||
.specialization = NULL,
|
||||
};
|
||||
|
||||
return RayPassCreateTracing( &rpc );
|
||||
|
|
|
@ -40,22 +40,6 @@ static const int semantics[] = {
|
|||
};
|
||||
|
||||
struct ray_pass_s *R_VkRayPrimaryPassCreate( void ) {
|
||||
// FIXME move this into vk_pipeline or something
|
||||
const struct SpecializationData {
|
||||
uint32_t sbt_record_size;
|
||||
} spec_data = {
|
||||
.sbt_record_size = vk_core.physical_device.sbt_record_size,
|
||||
};
|
||||
const VkSpecializationMapEntry spec_map[] = {
|
||||
{.constantID = SPEC_SBT_RECORD_SIZE_INDEX, .offset = offsetof(struct SpecializationData, sbt_record_size), .size = sizeof(uint32_t) },
|
||||
};
|
||||
const VkSpecializationInfo spec = {
|
||||
.mapEntryCount = COUNTOF(spec_map),
|
||||
.pMapEntries = spec_map,
|
||||
.dataSize = sizeof(spec_data),
|
||||
.pData = &spec_data,
|
||||
};
|
||||
|
||||
const ray_pass_shader_t miss[] = {
|
||||
"ray_primary.rmiss.spv"
|
||||
};
|
||||
|
@ -82,7 +66,7 @@ struct ray_pass_s *R_VkRayPrimaryPassCreate( void ) {
|
|||
.miss_count = COUNTOF(miss),
|
||||
.hit = hit,
|
||||
.hit_count = COUNTOF(hit),
|
||||
.specialization = &spec,
|
||||
.specialization = NULL,
|
||||
};
|
||||
|
||||
return RayPassCreateTracing( &rpc );
|
||||
|
|
Loading…
Reference in New Issue