diff options
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r-- | src/gallium/drivers/r300/r300_reg.h | 21 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_state_derived.c | 28 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_state_inlines.h | 48 |
3 files changed, 74 insertions, 23 deletions
diff --git a/src/gallium/drivers/r300/r300_reg.h b/src/gallium/drivers/r300/r300_reg.h index ae94bb9b9f..e920b2a5e7 100644 --- a/src/gallium/drivers/r300/r300_reg.h +++ b/src/gallium/drivers/r300/r300_reg.h @@ -348,6 +348,27 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. # define R300_WRITE_ENA_W 8 # define R300_SWIZZLE1_SHIFT 16 +# define R300_VAP_SWIZZLE_X001 \ + ((R300_SWIZZLE_SELECT_X << R300_SWIZZLE_SELECT_X_SHIFT) | \ + (R300_SWIZZLE_SELECT_FP_ZERO << R300_SWIZZLE_SELECT_Y_SHIFT) | \ + (R300_SWIZZLE_SELECT_FP_ZERO << R300_SWIZZLE_SELECT_Z_SHIFT) | \ + (R300_SWIZZLE_SELECT_FP_ONE << R300_SWIZZLE_SELECT_W_SHIFT) | \ + (0xf << R300_WRITE_ENA_SHIFT)) + +# define R300_VAP_SWIZZLE_XY01 \ + ((R300_SWIZZLE_SELECT_X << R300_SWIZZLE_SELECT_X_SHIFT) | \ + (R300_SWIZZLE_SELECT_Y << R300_SWIZZLE_SELECT_Y_SHIFT) | \ + (R300_SWIZZLE_SELECT_FP_ZERO << R300_SWIZZLE_SELECT_Z_SHIFT) | \ + (R300_SWIZZLE_SELECT_FP_ONE << R300_SWIZZLE_SELECT_W_SHIFT) | \ + (0xf << R300_WRITE_ENA_SHIFT)) + +# define R300_VAP_SWIZZLE_XYZ1 \ + ((R300_SWIZZLE_SELECT_X << R300_SWIZZLE_SELECT_X_SHIFT) | \ + (R300_SWIZZLE_SELECT_Y << R300_SWIZZLE_SELECT_Y_SHIFT) | \ + (R300_SWIZZLE_SELECT_Z << R300_SWIZZLE_SELECT_Z_SHIFT) | \ + (R300_SWIZZLE_SELECT_FP_ONE << R300_SWIZZLE_SELECT_W_SHIFT) | \ + (0xf << R300_WRITE_ENA_SHIFT)) + # define R300_VAP_SWIZZLE_XYZW \ ((R300_SWIZZLE_SELECT_X << R300_SWIZZLE_SELECT_X_SHIFT) | \ (R300_SWIZZLE_SELECT_Y << R300_SWIZZLE_SELECT_Y_SHIFT) | \ diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c index 42aee7231e..7d000e9e2d 100644 --- a/src/gallium/drivers/r300/r300_state_derived.c +++ b/src/gallium/drivers/r300/r300_state_derived.c @@ -224,7 +224,8 @@ static void r300_vertex_psc(struct r300_context* r300, struct r300_screen* r300screen = r300_screen(r300->context.screen); struct vertex_info* vinfo = &vformat->vinfo; int* tab = vformat->vs_tab; - uint32_t temp; + uint16_t type, swizzle; + enum pipe_format format; unsigned i, attrib_count; /* Vertex shaders have no semantics on their inputs, @@ -246,25 +247,28 @@ static void r300_vertex_psc(struct r300_context* r300, } for (i = 0; i < attrib_count; i++) { - /* Make sure we have a proper destination for our attribute */ + /* Make sure we have a proper destination for our attribute. */ assert(tab[i] != -1); - /* Add the attribute to the PSC table. */ - temp = translate_draw_vertex_data_type(vinfo->attrib[i].emit) | + format = draw_translate_vinfo_format(vinfo->attrib[i].emit); + + /* Obtain the type of data in this attribute. */ + type = r300_translate_vertex_data_type(format) | tab[i] << R300_DST_VEC_LOC_SHIFT; + /* Obtain the swizzle for this attribute. Note that the default + * swizzle in the hardware is not XYZW! */ + swizzle = r300_translate_vertex_data_swizzle(format); + + /* Add the attribute to the PSC table. */ if (i & 1) { - vformat->vap_prog_stream_cntl[i >> 1] &= 0x0000ffff; - vformat->vap_prog_stream_cntl[i >> 1] |= temp << 16; + vformat->vap_prog_stream_cntl[i >> 1] |= type << 16; - vformat->vap_prog_stream_cntl_ext[i >> 1] |= - (R300_VAP_SWIZZLE_XYZW << 16); + vformat->vap_prog_stream_cntl_ext[i >> 1] |= swizzle << 16; } else { - vformat->vap_prog_stream_cntl[i >> 1] &= 0xffff0000; - vformat->vap_prog_stream_cntl[i >> 1] |= temp << 0; + vformat->vap_prog_stream_cntl[i >> 1] |= type << 0; - vformat->vap_prog_stream_cntl_ext[i >> 1] |= - (R300_VAP_SWIZZLE_XYZW << 0); + vformat->vap_prog_stream_cntl_ext[i >> 1] |= swizzle << 0; } } diff --git a/src/gallium/drivers/r300/r300_state_inlines.h b/src/gallium/drivers/r300/r300_state_inlines.h index c82d8e5f08..2431b75a51 100644 --- a/src/gallium/drivers/r300/r300_state_inlines.h +++ b/src/gallium/drivers/r300/r300_state_inlines.h @@ -400,28 +400,54 @@ static INLINE uint32_t r300_translate_gb_pipes(int pipe_count) return 0; } -/* Translate Draw vertex types into PSC vertex types. */ -static INLINE uint32_t translate_draw_vertex_data_type(int type) { - switch (type) { - case EMIT_1F: - case EMIT_1F_PSIZE: +/* Translate pipe_formats into PSC vertex types. */ +static INLINE uint16_t +r300_translate_vertex_data_type(enum pipe_format format) { + switch (format) { + case PIPE_FORMAT_R32_FLOAT: return R300_DATA_TYPE_FLOAT_1; break; - case EMIT_2F: + case PIPE_FORMAT_R32G32_FLOAT: return R300_DATA_TYPE_FLOAT_2; break; - case EMIT_3F: + case PIPE_FORMAT_R32G32B32_FLOAT: return R300_DATA_TYPE_FLOAT_3; break; - case EMIT_4F: + case PIPE_FORMAT_R32G32B32A32_FLOAT: return R300_DATA_TYPE_FLOAT_4; break; - case EMIT_4UB: - return R300_DATA_TYPE_BYTE; + case PIPE_FORMAT_R8G8B8A8_UNORM: + return R300_DATA_TYPE_BYTE | + R300_NORMALIZE; + break; + default: + debug_printf("r300: Implementation error: " + "Bad vertex data format %s!\n", pf_name(format)); + assert(0); + break; + } + return 0; +} + +static INLINE uint16_t +r300_translate_vertex_data_swizzle(enum pipe_format format) { + switch (format) { + case PIPE_FORMAT_R32_FLOAT: + return R300_VAP_SWIZZLE_X001; + break; + case PIPE_FORMAT_R32G32_FLOAT: + return R300_VAP_SWIZZLE_XY01; + break; + case PIPE_FORMAT_R32G32B32_FLOAT: + return R300_VAP_SWIZZLE_XYZ1; + break; + case PIPE_FORMAT_R32G32B32A32_FLOAT: + case PIPE_FORMAT_R8G8B8A8_UNORM: + return R300_VAP_SWIZZLE_XYZW; break; default: debug_printf("r300: Implementation error: " - "Bad vertex data type!\n"); + "Bad vertex data format %s!\n", pf_name(format)); assert(0); break; } |