gallium: move border color to be a color union
authorDave Airlie <airlied@redhat.com>
Tue, 27 Sep 2011 09:08:34 +0000 (10:08 +0100)
committerDave Airlie <airlied@redhat.com>
Tue, 27 Sep 2011 19:02:02 +0000 (20:02 +0100)
EXT_texture_integer also specifies border color should be a color
union, the values are used according to the texture sampler format.

(update docs)

Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
19 files changed:
src/gallium/auxiliary/draw/draw_llvm.c
src/gallium/auxiliary/util/u_dump_state.c
src/gallium/docs/source/cso/sampler.rst
src/gallium/drivers/i915/i915_state.c
src/gallium/drivers/llvmpipe/lp_setup.c
src/gallium/drivers/nv50/nv50_state.c
src/gallium/drivers/nvfx/nvfx_fragtex.c
src/gallium/drivers/r300/r300_state_derived.c
src/gallium/drivers/r600/evergreen_state.c
src/gallium/drivers/r600/r600_state.c
src/gallium/drivers/softpipe/sp_tex_sample.c
src/gallium/drivers/svga/svga_pipe_sampler.c
src/gallium/drivers/trace/tr_dump_state.c
src/gallium/include/pipe/p_state.h
src/gallium/state_trackers/d3d1x/gd3d11/d3d11_context.h
src/gallium/state_trackers/d3d1x/gd3d11/d3d11_screen.h
src/gallium/state_trackers/vega/api_filters.c
src/gallium/state_trackers/vega/paint.c
src/mesa/state_tracker/st_atom_sampler.c

index 24f98588efdb30d547317c0bcae3373f7a23d47b..d427d2c9ced0b62cc8a1b8e0354573f87289dc0d 100644 (file)
@@ -1509,7 +1509,7 @@ draw_llvm_set_sampler_state(struct draw_context *draw)
          jit_tex->min_lod = draw->samplers[i]->min_lod;
          jit_tex->max_lod = draw->samplers[i]->max_lod;
          jit_tex->lod_bias = draw->samplers[i]->lod_bias;
-         COPY_4V(jit_tex->border_color, draw->samplers[i]->border_color);
+         COPY_4V(jit_tex->border_color, draw->samplers[i]->border_color.f);
       }
    }
 }
index 5ecf8cbb0674cc8ac598a2dcc0fce30c3057c1f4..6bb369966324a1aab510760d7e89604b21cc5a60 100644 (file)
@@ -617,7 +617,7 @@ util_dump_sampler_state(struct os_stream *stream, const struct pipe_sampler_stat
    util_dump_member(stream, float, state, lod_bias);
    util_dump_member(stream, float, state, min_lod);
    util_dump_member(stream, float, state, max_lod);
-   util_dump_member_array(stream, float, state, border_color);
+   util_dump_member_array(stream, float, state, border_color.f);
 
    util_dump_struct_end(stream);
 }
index 648b5cc60eab1295d85975538459ba5de478fa62..26ffc1810310d7b098e080679aa46e7f58a688f0 100644 (file)
@@ -99,8 +99,9 @@ min_lod
 max_lod
     Maximum level of detail, used to clamp LOD after bias.
 border_color
-    RGBA color used for texel coordinates that are outside the [0,width-1],
-    [0, height-1] or [0, depth-1] ranges.
+    Color union used for texel coordinates that are outside the [0,width-1],
+    [0, height-1] or [0, depth-1] ranges. Interpreted according to sampler
+    view format.
 max_anisotropy
     Maximum anistropy ratio to use when sampling from textures.  For example,
     if max_anistropy=4, a region of up to 1 by 4 texels will be sampled.
index 2812de1fe802aedd8da39aacd6b792c2f0fadf6f..345c109a995c7a561b817e7e1dca9ae2e6740627 100644 (file)
@@ -279,10 +279,10 @@ i915_create_sampler_state(struct pipe_context *pipe,
    }
 
    {
-      ubyte r = float_to_ubyte(sampler->border_color[0]);
-      ubyte g = float_to_ubyte(sampler->border_color[1]);
-      ubyte b = float_to_ubyte(sampler->border_color[2]);
-      ubyte a = float_to_ubyte(sampler->border_color[3]);
+      ubyte r = float_to_ubyte(sampler->border_color.f[0]);
+      ubyte g = float_to_ubyte(sampler->border_color.f[1]);
+      ubyte b = float_to_ubyte(sampler->border_color.f[2]);
+      ubyte a = float_to_ubyte(sampler->border_color.f[3]);
       cso->state[2] = I915PACKCOLOR8888(r, g, b, a);
    }
    return cso;
index cbe06e58a788a46b56388b5049a9cd7ad91448e8..1479ed44f0fca3d5afb59994f8003fd5c14fb296 100644 (file)
@@ -729,7 +729,7 @@ lp_setup_set_fragment_sampler_state(struct lp_setup_context *setup,
          jit_tex->min_lod = sampler->min_lod;
          jit_tex->max_lod = sampler->max_lod;
          jit_tex->lod_bias = sampler->lod_bias;
-         COPY_4V(jit_tex->border_color, sampler->border_color);
+         COPY_4V(jit_tex->border_color, sampler->border_color.f);
       }
    }
 
index 49ea646c77ceb2674a5dfcb74b72f2cf7db77a09..0e08b096f5876a03f3c323ee4f142e59fa8bc25b 100644 (file)
@@ -508,10 +508,10 @@ nv50_sampler_state_create(struct pipe_context *pipe,
    so->tsc[2] |=
       (((int)(f[1] * 256.0f) & 0xfff) << 12) | ((int)(f[0] * 256.0f) & 0xfff);
 
-   so->tsc[4] = fui(cso->border_color[0]);
-   so->tsc[5] = fui(cso->border_color[1]);
-   so->tsc[6] = fui(cso->border_color[2]);
-   so->tsc[7] = fui(cso->border_color[3]);
+   so->tsc[4] = fui(cso->border_color.f[0]);
+   so->tsc[5] = fui(cso->border_color.f[1]);
+   so->tsc[6] = fui(cso->border_color.f[2]);
+   so->tsc[7] = fui(cso->border_color.f[3]);
 
    return (void *)so;
 }
index 1c4901df0e2273572ae0614171337d07a4b505b5..3ef9fcce347e8507b9fcbfbf51b24f492a2586e7 100644 (file)
@@ -25,7 +25,7 @@ nvfx_sampler_state_create(struct pipe_context *pipe,
                ps->wrap |= nvfx_tex_wrap_compare_mode(cso->compare_func);
                ps->compare = TRUE;
        }
-       ps->bcol = nvfx_tex_border_color(cso->border_color);
+       ps->bcol = nvfx_tex_border_color(cso->border_color.f);
 
        if(nvfx->is_nv4x)
                nv40_sampler_state_init(pipe, ps, cso);
index 45c11fce1fe564436fc761db003e003579616bd7..daeb4d716d079773c195cf6b82296a127c5042ac 100644 (file)
@@ -762,7 +762,7 @@ static void r300_merge_textures_and_samplers(struct r300_context* r300)
             /* Set the border color. */
             texstate->border_color =
                 r300_get_border_color(view->base.format,
-                                      sampler->state.border_color,
+                                      sampler->state.border_color.f,
                                       r300->screen->caps.is_r500);
 
             /* determine min/max levels */
index 3b7844f0fa4a1dc59c74e8173ec5f5c355565eed..875c806b0a40f4677a5ebfc936048171633f5d16 100644 (file)
@@ -938,7 +938,7 @@ static void *evergreen_create_sampler_state(struct pipe_context *ctx,
        }
 
        rstate->id = R600_PIPE_STATE_SAMPLER;
-       util_pack_color(state->border_color, PIPE_FORMAT_B8G8R8A8_UNORM, &uc);
+       util_pack_color(state->border_color.f, PIPE_FORMAT_B8G8R8A8_UNORM, &uc);
        r600_pipe_state_add_reg_noblock(rstate, R_03C000_SQ_TEX_SAMPLER_WORD0_0,
                        S_03C000_CLAMP_X(r600_tex_wrap(state->wrap_s)) |
                        S_03C000_CLAMP_Y(r600_tex_wrap(state->wrap_t)) |
@@ -960,10 +960,10 @@ static void *evergreen_create_sampler_state(struct pipe_context *ctx,
                                        0xFFFFFFFF, NULL, 0);
 
        if (uc.ui) {
-               r600_pipe_state_add_reg_noblock(rstate, R_00A404_TD_PS_SAMPLER0_BORDER_RED, fui(state->border_color[0]), 0xFFFFFFFF, NULL, 0);
-               r600_pipe_state_add_reg_noblock(rstate, R_00A408_TD_PS_SAMPLER0_BORDER_GREEN, fui(state->border_color[1]), 0xFFFFFFFF, NULL, 0);
-               r600_pipe_state_add_reg_noblock(rstate, R_00A40C_TD_PS_SAMPLER0_BORDER_BLUE, fui(state->border_color[2]), 0xFFFFFFFF, NULL, 0);
-               r600_pipe_state_add_reg_noblock(rstate, R_00A410_TD_PS_SAMPLER0_BORDER_ALPHA, fui(state->border_color[3]), 0xFFFFFFFF, NULL, 0);
+               r600_pipe_state_add_reg_noblock(rstate, R_00A404_TD_PS_SAMPLER0_BORDER_RED, fui(state->border_color.f[0]), 0xFFFFFFFF, NULL, 0);
+               r600_pipe_state_add_reg_noblock(rstate, R_00A408_TD_PS_SAMPLER0_BORDER_GREEN, fui(state->border_color.f[1]), 0xFFFFFFFF, NULL, 0);
+               r600_pipe_state_add_reg_noblock(rstate, R_00A40C_TD_PS_SAMPLER0_BORDER_BLUE, fui(state->border_color.f[2]), 0xFFFFFFFF, NULL, 0);
+               r600_pipe_state_add_reg_noblock(rstate, R_00A410_TD_PS_SAMPLER0_BORDER_ALPHA, fui(state->border_color.f[3]), 0xFFFFFFFF, NULL, 0);
        }
        return rstate;
 }
index 2e2ce40d4476c4015c283558b18b2590f84ff194..6edf3857d92aaafdf48471cec7cf65685563de85 100644 (file)
@@ -981,7 +981,7 @@ static void *r600_create_sampler_state(struct pipe_context *ctx,
        ss->seamless_cube_map = state->seamless_cube_map;
        rstate = &ss->rstate;
        rstate->id = R600_PIPE_STATE_SAMPLER;
-       util_pack_color(state->border_color, PIPE_FORMAT_B8G8R8A8_UNORM, &uc);
+       util_pack_color(state->border_color.f, PIPE_FORMAT_B8G8R8A8_UNORM, &uc);
        r600_pipe_state_add_reg_noblock(rstate, R_03C000_SQ_TEX_SAMPLER_WORD0_0,
                                        S_03C000_CLAMP_X(r600_tex_wrap(state->wrap_s)) |
                                        S_03C000_CLAMP_Y(r600_tex_wrap(state->wrap_t)) |
@@ -998,10 +998,10 @@ static void *r600_create_sampler_state(struct pipe_context *ctx,
                                        S_03C004_LOD_BIAS(S_FIXED(CLAMP(state->lod_bias, -16, 16), 6)), 0xFFFFFFFF, NULL, 0);
        r600_pipe_state_add_reg_noblock(rstate, R_03C008_SQ_TEX_SAMPLER_WORD2_0, S_03C008_TYPE(1), 0xFFFFFFFF, NULL, 0);
        if (uc.ui) {
-               r600_pipe_state_add_reg_noblock(rstate, R_00A400_TD_PS_SAMPLER0_BORDER_RED, fui(state->border_color[0]), 0xFFFFFFFF, NULL, 0);
-               r600_pipe_state_add_reg_noblock(rstate, R_00A404_TD_PS_SAMPLER0_BORDER_GREEN, fui(state->border_color[1]), 0xFFFFFFFF, NULL, 0);
-               r600_pipe_state_add_reg_noblock(rstate, R_00A408_TD_PS_SAMPLER0_BORDER_BLUE, fui(state->border_color[2]), 0xFFFFFFFF, NULL, 0);
-               r600_pipe_state_add_reg_noblock(rstate, R_00A40C_TD_PS_SAMPLER0_BORDER_ALPHA, fui(state->border_color[3]), 0xFFFFFFFF, NULL, 0);
+               r600_pipe_state_add_reg_noblock(rstate, R_00A400_TD_PS_SAMPLER0_BORDER_RED, fui(state->border_color.f[0]), 0xFFFFFFFF, NULL, 0);
+               r600_pipe_state_add_reg_noblock(rstate, R_00A404_TD_PS_SAMPLER0_BORDER_GREEN, fui(state->border_color.f[1]), 0xFFFFFFFF, NULL, 0);
+               r600_pipe_state_add_reg_noblock(rstate, R_00A408_TD_PS_SAMPLER0_BORDER_BLUE, fui(state->border_color.f[2]), 0xFFFFFFFF, NULL, 0);
+               r600_pipe_state_add_reg_noblock(rstate, R_00A40C_TD_PS_SAMPLER0_BORDER_ALPHA, fui(state->border_color.f[3]), 0xFFFFFFFF, NULL, 0);
        }
        return rstate;
 }
index 2e91a709fe035beb3ac8c85269f9af5456319536..72629a0bcac49d96abd19d42fe5e46718ba93149 100644 (file)
@@ -672,7 +672,7 @@ get_texel_2d(const struct sp_sampler_variant *samp,
 
    if (x < 0 || x >= (int) u_minify(texture->width0, level) ||
        y < 0 || y >= (int) u_minify(texture->height0, level)) {
-      return samp->sampler->border_color;
+      return samp->sampler->border_color.f;
    }
    else {
       return get_texel_2d_no_border( samp, addr, x, y );
@@ -766,7 +766,7 @@ get_texel_3d(const struct sp_sampler_variant *samp,
    if (x < 0 || x >= (int) u_minify(texture->width0, level) ||
        y < 0 || y >= (int) u_minify(texture->height0, level) ||
        z < 0 || z >= (int) u_minify(texture->depth0, level)) {
-      return samp->sampler->border_color;
+      return samp->sampler->border_color.f;
    }
    else {
       return get_texel_3d_no_border( samp, addr, x, y, z );
@@ -783,7 +783,7 @@ get_texel_1d_array(const struct sp_sampler_variant *samp,
    unsigned level = addr.bits.level;
 
    if (x < 0 || x >= (int) u_minify(texture->width0, level)) {
-      return samp->sampler->border_color;
+      return samp->sampler->border_color.f;
    }
    else {
       return get_texel_2d_no_border(samp, addr, x, y);
@@ -803,7 +803,7 @@ get_texel_2d_array(const struct sp_sampler_variant *samp,
 
    if (x < 0 || x >= (int) u_minify(texture->width0, level) ||
        y < 0 || y >= (int) u_minify(texture->height0, level)) {
-      return samp->sampler->border_color;
+      return samp->sampler->border_color.f;
    }
    else {
       return get_texel_3d_no_border(samp, addr, x, y, layer);
index dcfeaacbef150d8d9d6d478f6b01b5dbe1c00836..4885d200584825b1924821e88d4e1b061956e7d8 100644 (file)
@@ -113,10 +113,10 @@ svga_create_sampler_state(struct pipe_context *pipe,
    cso->compare_func = sampler->compare_func;
 
    {
-      uint32 r = float_to_ubyte(sampler->border_color[0]);
-      uint32 g = float_to_ubyte(sampler->border_color[1]);
-      uint32 b = float_to_ubyte(sampler->border_color[2]);
-      uint32 a = float_to_ubyte(sampler->border_color[3]);
+      uint32 r = float_to_ubyte(sampler->border_color.f[0]);
+      uint32 g = float_to_ubyte(sampler->border_color.f[1]);
+      uint32 b = float_to_ubyte(sampler->border_color.f[2]);
+      uint32 a = float_to_ubyte(sampler->border_color.f[3]);
 
       cso->bordercolor = (a << 24) | (r << 16) | (g << 8) | b;
    }
index 291a6a29ca5ead138c0ef1ea0f0b5a940e0514e7..652ffa7a94bfc1dc0976867a9d9a0ccd829b32c4 100644 (file)
@@ -447,7 +447,7 @@ void trace_dump_sampler_state(const struct pipe_sampler_state *state)
    trace_dump_member(float, state, lod_bias);
    trace_dump_member(float, state, min_lod);
    trace_dump_member(float, state, max_lod);
-   trace_dump_member_array(float, state, border_color);
+   trace_dump_member_array(float, state, border_color.f);
 
    trace_dump_struct_end();
 }
index a57e805bd130c5ccf97b17d7a85cba27ae967fd6..90a856018525fcaa090f613dc35e0b949b0b9dbc 100644 (file)
@@ -272,7 +272,7 @@ struct pipe_sampler_state
    unsigned seamless_cube_map:1;
    float lod_bias;               /**< LOD/lambda bias */
    float min_lod, max_lod;       /**< LOD clamp range, after bias */
-   float border_color[4];
+   union pipe_color_union border_color;
 };
 
 
index 6cb19330f226a43286257a407cb15b2e35c8816d..6514146e367906ee0b27680bde9906f265fb8f19 100644 (file)
@@ -228,10 +228,10 @@ struct GalliumD3D10Device : public GalliumD3D10ScreenImpl<threadsafe>
                samplerd.wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
                samplerd.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
                samplerd.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
-               samplerd.border_color[0] = 1.0f;
-               samplerd.border_color[1] = 1.0f;
-               samplerd.border_color[2] = 1.0f;
-               samplerd.border_color[3] = 1.0f;
+               samplerd.border_color.f[0] = 1.0f;
+               samplerd.border_color.f[1] = 1.0f;
+               samplerd.border_color.f[2] = 1.0f;
+               samplerd.border_color.f[3] = 1.0f;
                samplerd.min_lod = -FLT_MAX;
                samplerd.max_lod = FLT_MAX;
                samplerd.max_anisotropy = 1;
index 3674731b1e1aa94468db2d54d99abf13536140c5..4405d33ea8a0e867b86bd7e701ae3ecbe7bacc95 100644 (file)
@@ -553,7 +553,7 @@ struct GalliumD3D11ScreenImpl : public GalliumD3D11Screen
                state.wrap_t = d3d11_to_pipe_wrap[sampler_desc->AddressV];
                state.wrap_r = d3d11_to_pipe_wrap[sampler_desc->AddressW];
                state.lod_bias = sampler_desc->MipLODBias;
-               memcpy(state.border_color, sampler_desc->BorderColor, sizeof(state.border_color));
+               memcpy(state.border_color.f, sampler_desc->BorderColor, sizeof(state.border_color));
                state.min_lod = sampler_desc->MinLOD;
                state.max_lod = sampler_desc->MaxLOD;
 
index 6be460c495c94cc6baaa7ab0c7f0eb89b68034f8..af824d91bd23cd4c659cdb4df98c78f06d6cf98c 100644 (file)
@@ -194,7 +194,7 @@ static void execute_filter(struct vg_context *ctx,
    case VG_TILE_FILL:
       tex_wrap = PIPE_TEX_WRAP_CLAMP_TO_BORDER;
       /* copy border color */
-      memcpy(sampler.border_color, ctx->state.vg.tile_fill_color,
+      memcpy(sampler.border_color.f, ctx->state.vg.tile_fill_color,
             sizeof(sampler.border_color));
       break;
    case VG_TILE_PAD:
index ea551811fcdb99671d9ddd05fa1b8b2b67b5437b..40b4b2502f18dbaeaf8755c9df3e5cda1ffebf28 100644 (file)
@@ -652,7 +652,7 @@ VGint paint_bind_samplers(struct vg_paint *paint, struct pipe_sampler_state **sa
    }
       break;
    case VG_PAINT_TYPE_PATTERN: {
-      memcpy(paint->pattern.sampler.border_color,
+      memcpy(paint->pattern.sampler.border_color.f,
              ctx->state.vg.tile_fill_color,
              sizeof(VGfloat) * 4);
       paint->pattern.sampler.min_img_filter = image_sampler_filter(ctx);
index 731338f9bebe18ecc600d5d9559ec196681db44b..ad159c64dc138aa6dc50e07164e26fe18454e651 100644 (file)
@@ -176,7 +176,7 @@ convert_sampler(struct st_context *st,
 
       st_translate_color(msamp->BorderColor.f,
                          teximg ? teximg->_BaseFormat : GL_RGBA,
-                         sampler->border_color);
+                         sampler->border_color.f);
    }
 
    sampler->max_anisotropy = (msamp->MaxAnisotropy == 1.0 ?