v3d_unit_data_create(0, const_offset));
const_offset = 0;
} else if (instr->intrinsic == nir_intrinsic_load_ubo) {
- uint32_t index = nir_src_as_uint(instr->src[0]);
- /* On OpenGL QUNIFORM_UBO_ADDR takes a UBO index
- * shifted up by 1 (0 is gallium's constant buffer 0).
+ /* QUNIFORM_UBO_ADDR takes a UBO index shifted up by 1 (0
+ * is gallium's constant buffer 0 in GL and push constants
+ * in Vulkan)).
*/
- if (c->key->environment == V3D_ENVIRONMENT_OPENGL)
- index++;
-
+ uint32_t index = nir_src_as_uint(instr->src[0]) + 1;
base_offset =
vir_uniform(c, QUNIFORM_UBO_ADDR,
v3d_unit_data_create(index, const_offset));
if (c->compiler->max_inline_uniform_buffers <= 0)
return false;
- /* On Vulkan we use indices 1..MAX_INLINE_UNIFORM_BUFFERS for inline
- * uniform buffers which we want to handle more like push constants
- * than regular UBO. OpenGL doesn't implement this feature.
- */
assert(c->key->environment == V3D_ENVIRONMENT_VULKAN);
+ /* Regular UBOs start after inline UBOs */
uint32_t index = nir_src_as_uint(instr->src[0]);
- if (index == 0 || index > c->compiler->max_inline_uniform_buffers)
+ if (index >= c->compiler->max_inline_uniform_buffers)
return false;
/* We scalarize general TMU access for anything that is not 32-bit */
instr->num_components == 1);
if (nir_src_is_const(instr->src[1])) {
- /* Index 0 is reserved for push constants */
- assert(index > 0);
- uint32_t inline_index = index - 1;
int offset = nir_src_as_uint(instr->src[1]);
if (try_emit_uniform(c, offset, instr->num_components,
&instr->dest,
- QUNIFORM_INLINE_UBO_0 + inline_index)) {
+ QUNIFORM_INLINE_UBO_0 + index)) {
return true;
}
}
*/
uint32_t index = is_uniform ? 0 : nir_src_as_uint(instr->src[0]);
- /* On OpenGL QUNIFORM_UBO_ADDR takes a UBO index
- * shifted up by 1 (0 is gallium's constant buffer 0).
+ /* QUNIFORM_UBO_ADDR takes a UBO index shifted up by 1 since we use
+ * index 0 for Gallium's constant buffer (GL) or push constants
+ * (Vulkan).
*/
- if (is_ubo && c->key->environment == V3D_ENVIRONMENT_OPENGL)
+ if (is_ubo)
index++;
/* We can only keep track of the last unifa address we used with
.lower_image = c->key->robust_image_access,
.lower_ssbo = c->key->robust_storage_access,
.lower_ubo = c->key->robust_uniform_access,
- .skip_ubo_0 = c->key->environment == V3D_ENVIRONMENT_VULKAN,
};
NIR_PASS(_, c->s, nir_lower_robust_access, &opts);
uint32_t start_index = 0;
if (binding_layout->type == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER ||
binding_layout->type == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) {
- start_index = MAX_INLINE_UNIFORM_BUFFERS;
+ start_index += MAX_INLINE_UNIFORM_BUFFERS;
}
index = descriptor_map_add(descriptor_map, set, binding,
start_index,
32 /* return_size: doesn't really apply for this case */,
0);
-
- /* We always reserve index 0 for push constants */
- if (binding_layout->type == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER ||
- binding_layout->type == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC ||
- binding_layout->type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK) {
- index++;
- }
-
break;
}
offset + dynamic_offset);
} else {
if (content == QUNIFORM_UBO_ADDR) {
- /* We reserve index 0 for push constants and artificially increase our
- * indices by one for that reason, fix that now before accessing the
- * descriptor map.
+ /* We reserve UBO index 0 for push constants in Vulkan (and for the
+ * constant buffer in GL) so the compiler always adds one to all UBO
+ * indices, fix it up before we access the descriptor map, since
+ * indices start from 0 there.
*/
assert(index > 0);
index--;