r600g/eg: add integer types support
authorDave Airlie <airlied@redhat.com>
Mon, 26 Sep 2011 18:06:40 +0000 (19:06 +0100)
committerDave Airlie <airlied@redhat.com>
Sun, 9 Oct 2011 09:06:18 +0000 (10:06 +0100)
adds handling for int texture/vertices to evergreen.

TODO r600/700 support.

Signed-off-by: Dave Airlie <airlied@redhat.com>
src/gallium/drivers/r600/evergreen_state.c
src/gallium/drivers/r600/r600_asm.c
src/gallium/drivers/r600/r600_texture.c

index a6fcfe089c80efbaee2180aa0d6ab740cc008885..bc16be7dd92145d600b61c5c8e68600dfc1cdcba 100644 (file)
@@ -281,10 +281,16 @@ static uint32_t r600_translate_colorswap(enum pipe_format format)
                return V_028C70_SWAP_ALT;
 
        case PIPE_FORMAT_A8_UNORM:
+       case PIPE_FORMAT_A8_UINT:
+       case PIPE_FORMAT_A8_SINT:
        case PIPE_FORMAT_R4A4_UNORM:
                return V_028C70_SWAP_ALT_REV;
        case PIPE_FORMAT_I8_UNORM:
        case PIPE_FORMAT_L8_UNORM:
+       case PIPE_FORMAT_I8_UINT:
+       case PIPE_FORMAT_I8_SINT:
+       case PIPE_FORMAT_L8_UINT:
+       case PIPE_FORMAT_L8_SINT:
        case PIPE_FORMAT_L8_SRGB:
        case PIPE_FORMAT_R8_UNORM:
        case PIPE_FORMAT_R8_SNORM:
@@ -306,12 +312,18 @@ static uint32_t r600_translate_colorswap(enum pipe_format format)
                return V_028C70_SWAP_STD;
 
        case PIPE_FORMAT_L8A8_UNORM:
+       case PIPE_FORMAT_L8A8_UINT:
+       case PIPE_FORMAT_L8A8_SINT:
        case PIPE_FORMAT_L8A8_SRGB:
                return V_028C70_SWAP_ALT;
        case PIPE_FORMAT_R8G8_UNORM:
+       case PIPE_FORMAT_R8G8_UINT:
+       case PIPE_FORMAT_R8G8_SINT:
                return V_028C70_SWAP_STD;
 
        case PIPE_FORMAT_R16_UNORM:
+       case PIPE_FORMAT_R16_UINT:
+       case PIPE_FORMAT_R16_SINT:
        case PIPE_FORMAT_R16_FLOAT:
                return V_028C70_SWAP_STD;
 
@@ -332,6 +344,8 @@ static uint32_t r600_translate_colorswap(enum pipe_format format)
        case PIPE_FORMAT_R8G8B8A8_UNORM:
        case PIPE_FORMAT_R8G8B8A8_SSCALED:
        case PIPE_FORMAT_R8G8B8A8_USCALED:
+       case PIPE_FORMAT_R8G8B8A8_SINT:
+       case PIPE_FORMAT_R8G8B8A8_UINT:
        case PIPE_FORMAT_R8G8B8X8_UNORM:
                return V_028C70_SWAP_STD;
 
@@ -358,17 +372,25 @@ static uint32_t r600_translate_colorswap(enum pipe_format format)
 
        case PIPE_FORMAT_R11G11B10_FLOAT:
        case PIPE_FORMAT_R32_FLOAT:
+       case PIPE_FORMAT_R32_UINT:
+       case PIPE_FORMAT_R32_SINT:
        case PIPE_FORMAT_Z32_FLOAT:
        case PIPE_FORMAT_R16G16_FLOAT:
        case PIPE_FORMAT_R16G16_UNORM:
+       case PIPE_FORMAT_R16G16_UINT:
+       case PIPE_FORMAT_R16G16_SINT:
                return V_028C70_SWAP_STD;
 
        /* 64-bit buffers. */
        case PIPE_FORMAT_R32G32_FLOAT:
+       case PIPE_FORMAT_R32G32_UINT:
+       case PIPE_FORMAT_R32G32_SINT:
        case PIPE_FORMAT_R16G16B16A16_UNORM:
        case PIPE_FORMAT_R16G16B16A16_SNORM:
        case PIPE_FORMAT_R16G16B16A16_USCALED:
        case PIPE_FORMAT_R16G16B16A16_SSCALED:
+       case PIPE_FORMAT_R16G16B16A16_UINT:
+       case PIPE_FORMAT_R16G16B16A16_SINT:
        case PIPE_FORMAT_R16G16B16A16_FLOAT:
        case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED:
 
@@ -378,6 +400,8 @@ static uint32_t r600_translate_colorswap(enum pipe_format format)
        case PIPE_FORMAT_R32G32B32A32_UNORM:
        case PIPE_FORMAT_R32G32B32A32_SSCALED:
        case PIPE_FORMAT_R32G32B32A32_USCALED:
+       case PIPE_FORMAT_R32G32B32A32_SINT:
+       case PIPE_FORMAT_R32G32B32A32_UINT:
                return V_028C70_SWAP_STD;
        default:
                R600_ERR("unsupported colorswap format %d\n", format);
@@ -396,11 +420,19 @@ static uint32_t r600_translate_colorformat(enum pipe_format format)
                return V_028C70_COLOR_4_4;
 
        case PIPE_FORMAT_A8_UNORM:
+       case PIPE_FORMAT_A8_UINT:
+       case PIPE_FORMAT_A8_SINT:
        case PIPE_FORMAT_I8_UNORM:
+       case PIPE_FORMAT_I8_UINT:
+       case PIPE_FORMAT_I8_SINT:
        case PIPE_FORMAT_L8_UNORM:
+       case PIPE_FORMAT_L8_UINT:
+       case PIPE_FORMAT_L8_SINT:
        case PIPE_FORMAT_L8_SRGB:
        case PIPE_FORMAT_R8_UNORM:
        case PIPE_FORMAT_R8_SNORM:
+       case PIPE_FORMAT_R8_UINT:
+       case PIPE_FORMAT_R8_SINT:
                return V_028C70_COLOR_8;
 
        /* 16-bit buffers. */
@@ -419,11 +451,17 @@ static uint32_t r600_translate_colorformat(enum pipe_format format)
                return V_028C70_COLOR_16;
 
        case PIPE_FORMAT_L8A8_UNORM:
+       case PIPE_FORMAT_L8A8_UINT:
+       case PIPE_FORMAT_L8A8_SINT:
        case PIPE_FORMAT_L8A8_SRGB:
        case PIPE_FORMAT_R8G8_UNORM:
+       case PIPE_FORMAT_R8G8_UINT:
+       case PIPE_FORMAT_R8G8_SINT:
                return V_028C70_COLOR_8_8;
 
        case PIPE_FORMAT_R16_UNORM:
+       case PIPE_FORMAT_R16_UINT:
+       case PIPE_FORMAT_R16_SINT:
                return V_028C70_COLOR_16;
 
        case PIPE_FORMAT_R16_FLOAT:
@@ -445,6 +483,8 @@ static uint32_t r600_translate_colorformat(enum pipe_format format)
        case PIPE_FORMAT_R8G8B8_UNORM:
        case PIPE_FORMAT_R8G8B8A8_SSCALED:
        case PIPE_FORMAT_R8G8B8A8_USCALED:
+       case PIPE_FORMAT_R8G8B8A8_SINT:
+       case PIPE_FORMAT_R8G8B8A8_UINT:
                return V_028C70_COLOR_8_8_8_8;
 
        case PIPE_FORMAT_R10G10B10A2_UNORM:
@@ -473,6 +513,8 @@ static uint32_t r600_translate_colorformat(enum pipe_format format)
 
        case PIPE_FORMAT_R16G16_SSCALED:
        case PIPE_FORMAT_R16G16_UNORM:
+       case PIPE_FORMAT_R16G16_UINT:
+       case PIPE_FORMAT_R16G16_SINT:
                return V_028C70_COLOR_16_16;
 
        case PIPE_FORMAT_R11G11B10_FLOAT:
@@ -481,6 +523,8 @@ static uint32_t r600_translate_colorformat(enum pipe_format format)
        /* 64-bit buffers. */
        case PIPE_FORMAT_R16G16B16_USCALED:
        case PIPE_FORMAT_R16G16B16_SSCALED:
+       case PIPE_FORMAT_R16G16B16A16_UINT:
+       case PIPE_FORMAT_R16G16B16A16_SINT:
        case PIPE_FORMAT_R16G16B16A16_USCALED:
        case PIPE_FORMAT_R16G16B16A16_SSCALED:
        case PIPE_FORMAT_R16G16B16A16_UNORM:
@@ -496,6 +540,8 @@ static uint32_t r600_translate_colorformat(enum pipe_format format)
 
        case PIPE_FORMAT_R32G32_USCALED:
        case PIPE_FORMAT_R32G32_SSCALED:
+       case PIPE_FORMAT_R32G32_SINT:
+       case PIPE_FORMAT_R32G32_UINT:
                return V_028C70_COLOR_32_32;
 
        /* 96-bit buffers. */
@@ -507,6 +553,8 @@ static uint32_t r600_translate_colorformat(enum pipe_format format)
        case PIPE_FORMAT_R32G32B32A32_UNORM:
        case PIPE_FORMAT_R32G32B32A32_SSCALED:
        case PIPE_FORMAT_R32G32B32A32_USCALED:
+       case PIPE_FORMAT_R32G32B32A32_SINT:
+       case PIPE_FORMAT_R32G32B32A32_UINT:
                return V_028C70_COLOR_32_32_32_32;
        case PIPE_FORMAT_R32G32B32A32_FLOAT:
                return V_028C70_COLOR_32_32_32_32_FLOAT;
@@ -1318,12 +1366,12 @@ static void evergreen_cb(struct r600_pipe_context *rctx, struct r600_pipe_state
        else if (desc->channel[i].type == UTIL_FORMAT_TYPE_SIGNED) {
                if (desc->channel[i].normalized)
                        ntype = V_028C70_NUMBER_SNORM;
-               else
+               else if (desc->channel[i].pure_integer)
                        ntype = V_028C70_NUMBER_SINT;
        } else if (desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED) {
                if (desc->channel[i].normalized)
                        ntype = V_028C70_NUMBER_UNORM;
-               else
+               else if (desc->channel[i].pure_integer)
                        ntype = V_028C70_NUMBER_UINT;
        } else
                ntype = V_028C70_NUMBER_UNORM;
index af0351b93c06fac1e9695993edde7db949f539b4..663e41f2dba2e2030b01703d790d147a398b2c03 100644 (file)
@@ -2017,8 +2017,9 @@ void r600_bytecode_dump(struct r600_bytecode *bc)
        fprintf(stderr, "--------------------------------------\n");
 }
 
-static void r600_vertex_data_type(enum pipe_format pformat, unsigned *format,
-                               unsigned *num_format, unsigned *format_comp, unsigned *endian)
+static void r600_vertex_data_type(enum pipe_format pformat,
+                                 unsigned *format,
+                                 unsigned *num_format, unsigned *format_comp, unsigned *endian)
 {
        const struct util_format_description *desc;
        unsigned i;
@@ -2146,10 +2147,16 @@ static void r600_vertex_data_type(enum pipe_format pformat, unsigned *format,
        if (desc->channel[i].type == UTIL_FORMAT_TYPE_SIGNED) {
                *format_comp = 1;
        }
-       if (desc->channel[i].normalized) {
-               *num_format = 0;
-       } else {
-               *num_format = 2;
+
+       *num_format = 0;
+       if (desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED ||
+           desc->channel[i].type == UTIL_FORMAT_TYPE_SIGNED) {
+               if (!desc->channel[i].normalized) {
+                       if (desc->channel[i].pure_integer)
+                               *num_format = 1;
+                       else
+                               *num_format = 2;
+               }
        }
        return;
 out_unknown:
@@ -2210,7 +2217,8 @@ int r600_vertex_elements_build_fetch_shader(struct r600_pipe_context *rctx, stru
 
        for (i = 0; i < ve->count; i++) {
                unsigned vbuffer_index;
-               r600_vertex_data_type(ve->elements[i].src_format, &format, &num_format, &format_comp, &endian);
+               r600_vertex_data_type(ve->elements[i].src_format,
+                                     &format, &num_format, &format_comp, &endian);
                desc = util_format_description(ve->elements[i].src_format);
                if (desc == NULL) {
                        r600_bytecode_clear(&bc);
index c3709b0cf54a2270f8c9d9c77bb939f26b971541..acb181139bf596e7e7212aa63a6e3d4ecdf1a019 100644 (file)
@@ -1061,7 +1061,7 @@ uint32_t r600_translate_texformat(struct pipe_screen *screen,
                }
 #endif
                if (desc->colorspace != UTIL_FORMAT_COLORSPACE_SRGB &&
-                   !desc->channel[i].normalized)
+                   desc->channel[i].pure_integer)
                        word4 |= S_038010_NUM_FORMAT_ALL(V_038010_SQ_NUM_FORMAT_INT);
 
                switch (desc->channel[i].size) {