mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 18:18:06 +02:00
draw/i915: move hwfmt array to i915 specific struct
There's no point in bloating the vertex_info struct everywhere with information that's only used by i915 in a single place. Let's explicitly store the hwinfo when needed, instead of piggy-backing on vertex_info. Reviewed-by: Emma Anholt <emma@anholt.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23851>
This commit is contained in:
parent
3f7ea95bc9
commit
bbcda63564
6 changed files with 20 additions and 18 deletions
|
|
@ -67,7 +67,6 @@ enum attrib_emit {
|
|||
struct vertex_info
|
||||
{
|
||||
unsigned num_attribs;
|
||||
uint32_t hwfmt[4]; /**< hardware format info for this format */
|
||||
unsigned size; /**< total vertex size in dwords */
|
||||
|
||||
/* Keep this small and at the end of the struct to allow quick
|
||||
|
|
|
|||
|
|
@ -155,7 +155,10 @@ struct i915_state {
|
|||
unsigned texbuffer[I915_TEX_UNITS][3];
|
||||
|
||||
/** Describes the current hardware vertex layout */
|
||||
struct vertex_info vertex_info;
|
||||
struct i915_vertex_info {
|
||||
struct vertex_info draw; /** vertex_info from draw_module */
|
||||
uint32_t hwfmt[4]; /** Hardware format info */
|
||||
} vertex_info;
|
||||
|
||||
/* static state (dst/depth buffer state) */
|
||||
struct i915_winsys_buffer *cbuf_bo;
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ setup_stage(struct draw_stage *stage)
|
|||
static inline void
|
||||
emit_hw_vertex(struct i915_context *i915, const struct vertex_header *vertex)
|
||||
{
|
||||
const struct vertex_info *vinfo = &i915->current.vertex_info;
|
||||
const struct vertex_info *vinfo = &i915->current.vertex_info.draw;
|
||||
uint32_t i;
|
||||
uint32_t count = 0; /* for debug/sanity */
|
||||
|
||||
|
|
@ -129,7 +129,7 @@ emit_prim(struct draw_stage *stage, struct prim_header *prim, unsigned hwprim,
|
|||
i915_emit_hardware_state(i915);
|
||||
|
||||
/* need to do this after validation! */
|
||||
vertex_size = i915->current.vertex_info.size * 4; /* in bytes */
|
||||
vertex_size = i915->current.vertex_info.draw.size * 4; /* in bytes */
|
||||
assert(vertex_size >= 12); /* never smaller than 12 bytes */
|
||||
|
||||
if (!BEGIN_BATCH(1 + nr * vertex_size / 4)) {
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ i915_vbuf_render_get_vertex_info(struct vbuf_render *render)
|
|||
i915_update_derived(i915);
|
||||
}
|
||||
|
||||
return &i915->current.vertex_info;
|
||||
return &i915->current.vertex_info.draw;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ static void
|
|||
calculate_vertex_layout(struct i915_context *i915)
|
||||
{
|
||||
const struct i915_fragment_shader *fs = i915->fs;
|
||||
struct vertex_info vinfo;
|
||||
struct i915_vertex_info vinfo;
|
||||
bool colors[2], fog, needW, face;
|
||||
uint32_t i;
|
||||
int src;
|
||||
|
|
@ -84,20 +84,20 @@ calculate_vertex_layout(struct i915_context *i915)
|
|||
/* pos */
|
||||
src = draw_find_shader_output(i915->draw, TGSI_SEMANTIC_POSITION, 0);
|
||||
if (needW) {
|
||||
draw_emit_vertex_attr(&vinfo, EMIT_4F, src);
|
||||
draw_emit_vertex_attr(&vinfo.draw, EMIT_4F, src);
|
||||
vinfo.hwfmt[0] |= S4_VFMT_XYZW;
|
||||
vinfo.attrib[0].emit = EMIT_4F;
|
||||
vinfo.draw.attrib[0].emit = EMIT_4F;
|
||||
} else {
|
||||
draw_emit_vertex_attr(&vinfo, EMIT_3F, src);
|
||||
draw_emit_vertex_attr(&vinfo.draw, EMIT_3F, src);
|
||||
vinfo.hwfmt[0] |= S4_VFMT_XYZ;
|
||||
vinfo.attrib[0].emit = EMIT_3F;
|
||||
vinfo.draw.attrib[0].emit = EMIT_3F;
|
||||
}
|
||||
|
||||
/* point size. if not emitted here, then point size comes from LIS4. */
|
||||
if (i915->rasterizer->templ.point_size_per_vertex) {
|
||||
src = draw_find_shader_output(i915->draw, TGSI_SEMANTIC_PSIZE, 0);
|
||||
if (src != -1) {
|
||||
draw_emit_vertex_attr(&vinfo, EMIT_1F, src);
|
||||
draw_emit_vertex_attr(&vinfo.draw, EMIT_1F, src);
|
||||
vinfo.hwfmt[0] |= S4_VFMT_POINT_WIDTH;
|
||||
}
|
||||
}
|
||||
|
|
@ -105,21 +105,21 @@ calculate_vertex_layout(struct i915_context *i915)
|
|||
/* primary color */
|
||||
if (colors[0]) {
|
||||
src = draw_find_shader_output(i915->draw, TGSI_SEMANTIC_COLOR, 0);
|
||||
draw_emit_vertex_attr(&vinfo, EMIT_4UB_BGRA, src);
|
||||
draw_emit_vertex_attr(&vinfo.draw, EMIT_4UB_BGRA, src);
|
||||
vinfo.hwfmt[0] |= S4_VFMT_COLOR;
|
||||
}
|
||||
|
||||
/* secondary color */
|
||||
if (colors[1]) {
|
||||
src = draw_find_shader_output(i915->draw, TGSI_SEMANTIC_COLOR, 1);
|
||||
draw_emit_vertex_attr(&vinfo, EMIT_4UB_BGRA, src);
|
||||
draw_emit_vertex_attr(&vinfo.draw, EMIT_4UB_BGRA, src);
|
||||
vinfo.hwfmt[0] |= S4_VFMT_SPEC_FOG;
|
||||
}
|
||||
|
||||
/* fog coord, not fog blend factor */
|
||||
if (fog) {
|
||||
src = draw_find_shader_output(i915->draw, TGSI_SEMANTIC_FOG, 0);
|
||||
draw_emit_vertex_attr(&vinfo, EMIT_1F, src);
|
||||
draw_emit_vertex_attr(&vinfo.draw, EMIT_1F, src);
|
||||
vinfo.hwfmt[0] |= S4_VFMT_FOG_PARAM;
|
||||
}
|
||||
|
||||
|
|
@ -135,11 +135,11 @@ calculate_vertex_layout(struct i915_context *i915)
|
|||
* the draw module by adding an extra shader output.
|
||||
*/
|
||||
mesa_loge("Front/back face is broken\n");
|
||||
draw_emit_vertex_attr(&vinfo, EMIT_1F, src);
|
||||
draw_emit_vertex_attr(&vinfo.draw, EMIT_1F, src);
|
||||
hwtc = TEXCOORDFMT_1D;
|
||||
} else {
|
||||
hwtc = TEXCOORDFMT_4D;
|
||||
draw_emit_vertex_attr(&vinfo, EMIT_4F, src);
|
||||
draw_emit_vertex_attr(&vinfo.draw, EMIT_4F, src);
|
||||
}
|
||||
} else {
|
||||
hwtc = TEXCOORDFMT_NOT_PRESENT;
|
||||
|
|
@ -147,7 +147,7 @@ calculate_vertex_layout(struct i915_context *i915)
|
|||
vinfo.hwfmt[1] |= hwtc << (i * 4);
|
||||
}
|
||||
|
||||
draw_compute_vertex_size(&vinfo);
|
||||
draw_compute_vertex_size(&vinfo.draw);
|
||||
|
||||
if (memcmp(&i915->current.vertex_info, &vinfo, sizeof(vinfo))) {
|
||||
/* Need to set this flag so that the LIS2/4 registers get set.
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ upload_S0S1(struct i915_context *i915)
|
|||
/* I915_NEW_VERTEX_SIZE
|
||||
*/
|
||||
{
|
||||
unsigned vertex_size = i915->current.vertex_info.size;
|
||||
unsigned vertex_size = i915->current.vertex_info.draw.size;
|
||||
|
||||
LIS1 = ((vertex_size << 24) | (vertex_size << 16));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue