gallium: move border color to be a color union
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>
diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c
index 24f9858..d427d2c 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_llvm.c
@@ -1509,7 +1509,7 @@
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);
}
}
}
diff --git a/src/gallium/auxiliary/util/u_dump_state.c b/src/gallium/auxiliary/util/u_dump_state.c
index 5ecf8cb..6bb3699 100644
--- a/src/gallium/auxiliary/util/u_dump_state.c
+++ b/src/gallium/auxiliary/util/u_dump_state.c
@@ -617,7 +617,7 @@
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);
}
diff --git a/src/gallium/docs/source/cso/sampler.rst b/src/gallium/docs/source/cso/sampler.rst
index 648b5cc..26ffc18 100644
--- a/src/gallium/docs/source/cso/sampler.rst
+++ b/src/gallium/docs/source/cso/sampler.rst
@@ -99,8 +99,9 @@
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.
diff --git a/src/gallium/drivers/i915/i915_state.c b/src/gallium/drivers/i915/i915_state.c
index 2812de1..345c109 100644
--- a/src/gallium/drivers/i915/i915_state.c
+++ b/src/gallium/drivers/i915/i915_state.c
@@ -279,10 +279,10 @@
}
{
- 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;
diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c
index cbe06e5..1479ed4 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup.c
@@ -729,7 +729,7 @@
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);
}
}
diff --git a/src/gallium/drivers/nv50/nv50_state.c b/src/gallium/drivers/nv50/nv50_state.c
index 49ea646..0e08b09 100644
--- a/src/gallium/drivers/nv50/nv50_state.c
+++ b/src/gallium/drivers/nv50/nv50_state.c
@@ -508,10 +508,10 @@
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;
}
diff --git a/src/gallium/drivers/nvfx/nvfx_fragtex.c b/src/gallium/drivers/nvfx/nvfx_fragtex.c
index 1c4901d..3ef9fcc 100644
--- a/src/gallium/drivers/nvfx/nvfx_fragtex.c
+++ b/src/gallium/drivers/nvfx/nvfx_fragtex.c
@@ -25,7 +25,7 @@
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);
diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c
index 45c11fc..daeb4d71 100644
--- a/src/gallium/drivers/r300/r300_state_derived.c
+++ b/src/gallium/drivers/r300/r300_state_derived.c
@@ -762,7 +762,7 @@
/* 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 */
diff --git a/src/gallium/drivers/r600/evergreen_state.c b/src/gallium/drivers/r600/evergreen_state.c
index 3b7844f..875c806 100644
--- a/src/gallium/drivers/r600/evergreen_state.c
+++ b/src/gallium/drivers/r600/evergreen_state.c
@@ -938,7 +938,7 @@
}
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 @@
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;
}
diff --git a/src/gallium/drivers/r600/r600_state.c b/src/gallium/drivers/r600/r600_state.c
index 2e2ce40..6edf385 100644
--- a/src/gallium/drivers/r600/r600_state.c
+++ b/src/gallium/drivers/r600/r600_state.c
@@ -981,7 +981,7 @@
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 @@
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;
}
diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.c b/src/gallium/drivers/softpipe/sp_tex_sample.c
index 2e91a70..72629a0 100644
--- a/src/gallium/drivers/softpipe/sp_tex_sample.c
+++ b/src/gallium/drivers/softpipe/sp_tex_sample.c
@@ -672,7 +672,7 @@
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 @@
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 @@
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 @@
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);
diff --git a/src/gallium/drivers/svga/svga_pipe_sampler.c b/src/gallium/drivers/svga/svga_pipe_sampler.c
index dcfeaac..4885d20 100644
--- a/src/gallium/drivers/svga/svga_pipe_sampler.c
+++ b/src/gallium/drivers/svga/svga_pipe_sampler.c
@@ -113,10 +113,10 @@
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;
}
diff --git a/src/gallium/drivers/trace/tr_dump_state.c b/src/gallium/drivers/trace/tr_dump_state.c
index 291a6a2..652ffa7 100644
--- a/src/gallium/drivers/trace/tr_dump_state.c
+++ b/src/gallium/drivers/trace/tr_dump_state.c
@@ -447,7 +447,7 @@
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();
}
diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h
index a57e805..90a8560 100644
--- a/src/gallium/include/pipe/p_state.h
+++ b/src/gallium/include/pipe/p_state.h
@@ -272,7 +272,7 @@
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;
};
diff --git a/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_context.h b/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_context.h
index 6cb1933..6514146 100644
--- a/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_context.h
+++ b/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_context.h
@@ -228,10 +228,10 @@
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;
diff --git a/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_screen.h b/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_screen.h
index 3674731..4405d33 100644
--- a/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_screen.h
+++ b/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_screen.h
@@ -553,7 +553,7 @@
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;
diff --git a/src/gallium/state_trackers/vega/api_filters.c b/src/gallium/state_trackers/vega/api_filters.c
index 6be460c..af824d9 100644
--- a/src/gallium/state_trackers/vega/api_filters.c
+++ b/src/gallium/state_trackers/vega/api_filters.c
@@ -194,7 +194,7 @@
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:
diff --git a/src/gallium/state_trackers/vega/paint.c b/src/gallium/state_trackers/vega/paint.c
index ea55181..40b4b25 100644
--- a/src/gallium/state_trackers/vega/paint.c
+++ b/src/gallium/state_trackers/vega/paint.c
@@ -652,7 +652,7 @@
}
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);
diff --git a/src/mesa/state_tracker/st_atom_sampler.c b/src/mesa/state_tracker/st_atom_sampler.c
index 731338f..ad159c6 100644
--- a/src/mesa/state_tracker/st_atom_sampler.c
+++ b/src/mesa/state_tracker/st_atom_sampler.c
@@ -176,7 +176,7 @@
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 ?