constant_index = child->base_offset;
}
- if (desc_type == DESC_SAMPLER && binding->immutable_samplers &&
+ if (desc_type == DESC_SAMPLER && binding->immutable_samplers_offset &&
(!index || binding->immutable_samplers_equal)) {
if (binding->immutable_samplers_equal)
constant_index = 0;
+ const uint32_t *samplers = radv_immutable_samplers(layout, binding);
+
LLVMValueRef constants[] = {
- LLVMConstInt(ctx->i32, binding->immutable_samplers[constant_index * 4 + 0], 0),
- LLVMConstInt(ctx->i32, binding->immutable_samplers[constant_index * 4 + 1], 0),
- LLVMConstInt(ctx->i32, binding->immutable_samplers[constant_index * 4 + 2], 0),
- LLVMConstInt(ctx->i32, binding->immutable_samplers[constant_index * 4 + 3], 0),
+ LLVMConstInt(ctx->i32, samplers[constant_index * 4 + 0], 0),
+ LLVMConstInt(ctx->i32, samplers[constant_index * 4 + 1], 0),
+ LLVMConstInt(ctx->i32, samplers[constant_index * 4 + 2], 0),
+ LLVMConstInt(ctx->i32, samplers[constant_index * 4 + 3], 0),
};
return ac_build_gather_values(&ctx->ac, constants, 4);
}
immutable_sampler_count += pCreateInfo->pBindings[j].descriptorCount;
}
- size_t size = sizeof(struct radv_descriptor_set_layout) +
- (max_binding + 1) * sizeof(set_layout->binding[0]) +
- immutable_sampler_count * 4 * sizeof(uint32_t);
+ uint32_t samplers_offset = sizeof(struct radv_descriptor_set_layout) +
+ (max_binding + 1) * sizeof(set_layout->binding[0]);
+ size_t size = samplers_offset + immutable_sampler_count * 4 * sizeof(uint32_t);
set_layout = vk_alloc2(&device->alloc, pAllocator, size, 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
set_layout->binding[b].dynamic_offset_offset = dynamic_offset_count;
if (binding->pImmutableSamplers) {
- set_layout->binding[b].immutable_samplers = samplers;
+ set_layout->binding[b].immutable_samplers_offset = samplers_offset;
set_layout->binding[b].immutable_samplers_equal = true;
- samplers += 4 * binding->descriptorCount;
+
for (uint32_t i = 0; i < binding->descriptorCount; i++)
- memcpy(set_layout->binding[b].immutable_samplers + 4 * i, &radv_sampler_from_handle(binding->pImmutableSamplers[i])->state, 16);
+ memcpy(samplers + 4 * i, &radv_sampler_from_handle(binding->pImmutableSamplers[i])->state, 16);
for (uint32_t i = 1; i < binding->descriptorCount; i++)
- if (memcmp(set_layout->binding[b].immutable_samplers + 4 * i,
- set_layout->binding[b].immutable_samplers, 16) != 0)
+ if (memcmp(samplers + 4 * i, samplers, 16) != 0)
set_layout->binding[b].immutable_samplers_equal = false;
/* Don't reserve space for the samplers if they're not accessed. */
else if (binding->descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER)
set_layout->binding[b].size -= 16;
}
+ samplers += 4 * binding->descriptorCount;
+ samplers_offset += 4 * sizeof(uint32_t) * binding->descriptorCount;
}
set_layout->size += binding->descriptorCount * set_layout->binding[b].size;
}
for (unsigned i = 0; i < layout->binding_count; ++i) {
- if (!layout->binding[i].immutable_samplers ||
+ if (!layout->binding[i].immutable_samplers_offset ||
layout->binding[i].immutable_samplers_equal)
continue;
if (layout->binding[i].type == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)
offset += 16;
+ const uint32_t *samplers = (const uint32_t*)((const char*)layout + layout->binding[i].immutable_samplers_offset);
for (unsigned j = 0; j < layout->binding[i].array_size; ++j) {
- memcpy(set->mapped_ptr + offset, layout->binding[i].immutable_samplers + 4 * j, 16);
+ memcpy(set->mapped_ptr + offset, samplers + 4 * j, 16);
offset += layout->binding[i].size / 4;
}
* immutable samplers into them now.
*/
const bool copy_immutable_samplers = cmd_buffer &&
- binding_layout->immutable_samplers && !binding_layout->immutable_samplers_equal;
+ binding_layout->immutable_samplers_offset && !binding_layout->immutable_samplers_equal;
+ const uint32_t *samplers = radv_immutable_samplers(set->layout, binding_layout);
ptr += binding_layout->offset / 4;
ptr += binding_layout->size * writeset->dstArrayElement / 4;
case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
write_combined_image_sampler_descriptor(device, cmd_buffer, ptr, buffer_list,
writeset->pImageInfo + j,
- !binding_layout->immutable_samplers);
+ !binding_layout->immutable_samplers_offset);
if (copy_immutable_samplers) {
const unsigned idx = writeset->dstArrayElement + j;
- memcpy(ptr + 16, binding_layout->immutable_samplers + 4 * idx, 16);
+ memcpy(ptr + 16, samplers + 4 * idx, 16);
}
break;
case VK_DESCRIPTOR_TYPE_SAMPLER:
- if (!binding_layout->immutable_samplers) {
+ if (!binding_layout->immutable_samplers_offset) {
write_sampler_descriptor(device, ptr,
writeset->pImageInfo + j);
} else if (copy_immutable_samplers) {
unsigned idx = writeset->dstArrayElement + j;
- memcpy(ptr, binding_layout->immutable_samplers + 4 * idx, 16);
+ memcpy(ptr, samplers + 4 * idx, 16);
}
break;
default:
set_layout->binding + entry->dstBinding;
const uint32_t buffer_offset = binding_layout->buffer_offset +
binding_layout->buffer_count * entry->dstArrayElement;
- uint32_t *immutable_samplers = NULL;
+ const uint32_t *immutable_samplers = NULL;
uint16_t dst_offset;
uint16_t dst_stride;
case VK_DESCRIPTOR_TYPE_SAMPLER:
/* Immutable samplers are copied into push descriptors when they are pushed */
if (pCreateInfo->templateType == VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_PUSH_DESCRIPTORS_KHR &&
- binding_layout->immutable_samplers && !binding_layout->immutable_samplers_equal)
- immutable_samplers = binding_layout->immutable_samplers + entry->dstArrayElement * 4;
+ binding_layout->immutable_samplers_offset && !binding_layout->immutable_samplers_equal) {
+ immutable_samplers = radv_immutable_samplers(set_layout, binding_layout) + entry->dstArrayElement * 4;
+ }
break;
default:
break;
.dst_stride = dst_stride,
.buffer_offset = buffer_offset,
.buffer_count = binding_layout->buffer_count,
- .has_sampler = !binding_layout->immutable_samplers,
+ .has_sampler = !binding_layout->immutable_samplers_offset,
.immutable_samplers = immutable_samplers
};
}