Browse Source

nir: pack nir_variable::data::xfb_*

Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
merge-requests/2593/head
Marek Olšák 5 years ago
parent
commit
4319cc8c0f

+ 7
- 4
src/compiler/glsl/glsl_to_nir.cpp View File

@@ -600,14 +600,17 @@ nir_visitor::visit(ir_variable *ir)
var->data.bindless = ir->data.bindless;
var->data.offset = ir->data.offset;

var->data.image.access = (gl_access_qualifier)image_access;
var->data.image.format = ir->data.image_format;
if (var->type->is_image()) {
var->data.image.access = (gl_access_qualifier)image_access;
var->data.image.format = ir->data.image_format;
} else {
var->data.xfb.buffer = ir->data.xfb_buffer;
var->data.xfb.stride = ir->data.xfb_stride;
}

var->data.fb_fetch_output = ir->data.fb_fetch_output;
var->data.explicit_xfb_buffer = ir->data.explicit_xfb_buffer;
var->data.explicit_xfb_stride = ir->data.explicit_xfb_stride;
var->data.xfb_buffer = ir->data.xfb_buffer;
var->data.xfb_stride = ir->data.xfb_stride;

var->num_state_slots = ir->get_num_state_slots();
if (var->num_state_slots > 0) {

+ 23
- 19
src/compiler/nir/nir.h View File

@@ -478,25 +478,29 @@ typedef struct nir_variable {
*/
unsigned offset;

/**
* Transform feedback buffer.
*/
unsigned xfb_buffer;

/**
* Transform feedback stride.
*/
unsigned xfb_stride;

/**
* ARB_shader_image_load_store qualifiers.
*/
struct {
enum gl_access_qualifier access;

/** Image internal format if specified explicitly, otherwise GL_NONE. */
GLenum format;
} image;
union {
/**
* ARB_shader_image_load_store qualifiers.
*/
struct {
enum gl_access_qualifier access;

/** Image internal format if specified explicitly, otherwise GL_NONE. */
GLenum format;
} image;

struct {
/**
* Transform feedback buffer.
*/
uint16_t buffer:2;

/**
* Transform feedback stride.
*/
uint16_t stride;
} xfb;
};
} data;

/* Number of nir_variable_data members */

+ 6
- 6
src/compiler/nir/nir_gather_xfb_info.c View File

@@ -38,9 +38,9 @@ add_var_xfb_varying(nir_xfb_info *xfb,
nir_xfb_varying_info *varying = &varyings->varyings[varyings->varying_count++];

varying->type = type;
varying->buffer = var->data.xfb_buffer;
varying->buffer = var->data.xfb.buffer;
varying->offset = offset;
xfb->buffers[var->data.xfb_buffer].varying_count++;
xfb->buffers[var->data.xfb.buffer].varying_count++;
}


@@ -100,11 +100,11 @@ add_var_xfb_outputs(nir_xfb_info *xfb,
} else {
assert(buffer < NIR_MAX_XFB_BUFFERS);
if (xfb->buffers_written & (1 << buffer)) {
assert(xfb->buffers[buffer].stride == var->data.xfb_stride);
assert(xfb->buffers[buffer].stride == var->data.xfb.stride);
assert(xfb->buffer_to_stream[buffer] == var->data.stream);
} else {
xfb->buffers_written |= (1 << buffer);
xfb->buffers[buffer].stride = var->data.xfb_stride;
xfb->buffers[buffer].stride = var->data.xfb.stride;
xfb->buffer_to_stream[buffer] = var->data.stream;
}

@@ -235,7 +235,7 @@ nir_gather_xfb_info_with_varyings(const nir_shader *shader,

if (var->data.explicit_offset && !is_array_block) {
unsigned offset = var->data.offset;
add_var_xfb_outputs(xfb, varyings_info, var, var->data.xfb_buffer,
add_var_xfb_outputs(xfb, varyings_info, var, var->data.xfb.buffer,
&location, &offset, var->type, false);
} else if (is_array_block) {
assert(glsl_type_is_struct_or_ifc(var->interface_type));
@@ -253,7 +253,7 @@ nir_gather_xfb_info_with_varyings(const nir_shader *shader,
}

unsigned offset = foffset;
add_var_xfb_outputs(xfb, varyings_info, var, var->data.xfb_buffer + b,
add_var_xfb_outputs(xfb, varyings_info, var, var->data.xfb.buffer + b,
&location, &offset, ftype, false);
}
}

+ 2
- 2
src/compiler/spirv/vtn_variables.c View File

@@ -1586,12 +1586,12 @@ apply_var_decoration(struct vtn_builder *b,

case SpvDecorationXfbBuffer:
var_data->explicit_xfb_buffer = true;
var_data->xfb_buffer = dec->operands[0];
var_data->xfb.buffer = dec->operands[0];
var_data->always_active_io = true;
break;
case SpvDecorationXfbStride:
var_data->explicit_xfb_stride = true;
var_data->xfb_stride = dec->operands[0];
var_data->xfb.stride = dec->operands[0];
break;
case SpvDecorationOffset:
var_data->explicit_offset = true;

Loading…
Cancel
Save