mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-27 12:40:09 +01:00
gallivm: More comprehensive border usage logic.
This commit is contained in:
parent
e2b51b7c5b
commit
4e6f5e8d43
3 changed files with 51 additions and 29 deletions
|
|
@ -45,6 +45,39 @@
|
|||
#include "lp_bld_type.h"
|
||||
|
||||
|
||||
/**
|
||||
* Does the given texture wrap mode allow sampling the texture border color?
|
||||
* XXX maybe move this into gallium util code.
|
||||
*/
|
||||
boolean
|
||||
lp_sampler_wrap_mode_uses_border_color(unsigned mode,
|
||||
unsigned min_img_filter,
|
||||
unsigned mag_img_filter)
|
||||
{
|
||||
switch (mode) {
|
||||
case PIPE_TEX_WRAP_REPEAT:
|
||||
case PIPE_TEX_WRAP_CLAMP_TO_EDGE:
|
||||
case PIPE_TEX_WRAP_MIRROR_REPEAT:
|
||||
case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE:
|
||||
return FALSE;
|
||||
case PIPE_TEX_WRAP_CLAMP:
|
||||
case PIPE_TEX_WRAP_MIRROR_CLAMP:
|
||||
if (min_img_filter == PIPE_TEX_FILTER_NEAREST &&
|
||||
mag_img_filter == PIPE_TEX_FILTER_NEAREST) {
|
||||
return FALSE;
|
||||
} else {
|
||||
return TRUE;
|
||||
}
|
||||
case PIPE_TEX_WRAP_CLAMP_TO_BORDER:
|
||||
case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER:
|
||||
return TRUE;
|
||||
default:
|
||||
assert(0 && "unexpected wrap mode");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialize lp_sampler_static_state object with the gallium sampler
|
||||
* and texture state.
|
||||
|
|
|
|||
|
|
@ -254,6 +254,11 @@ texture_dims(enum pipe_texture_target tex)
|
|||
}
|
||||
|
||||
|
||||
boolean
|
||||
lp_sampler_wrap_mode_uses_border_color(unsigned mode,
|
||||
unsigned min_img_filter,
|
||||
unsigned mag_img_filter);
|
||||
|
||||
/**
|
||||
* Derive the sampler static state.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -58,31 +58,6 @@
|
|||
#include "lp_bld_quad.h"
|
||||
|
||||
|
||||
/**
|
||||
* Does the given texture wrap mode allow sampling the texture border color?
|
||||
* XXX maybe move this into gallium util code.
|
||||
*/
|
||||
static boolean
|
||||
wrap_mode_uses_border_color(unsigned mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case PIPE_TEX_WRAP_REPEAT:
|
||||
case PIPE_TEX_WRAP_CLAMP_TO_EDGE:
|
||||
case PIPE_TEX_WRAP_MIRROR_REPEAT:
|
||||
case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE:
|
||||
return FALSE;
|
||||
case PIPE_TEX_WRAP_CLAMP:
|
||||
case PIPE_TEX_WRAP_CLAMP_TO_BORDER:
|
||||
case PIPE_TEX_WRAP_MIRROR_CLAMP:
|
||||
case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER:
|
||||
return TRUE;
|
||||
default:
|
||||
assert(0 && "unexpected wrap mode");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generate code to fetch a texel from a texture at int coords (x, y, z).
|
||||
* The computation depends on whether the texture is 1D, 2D or 3D.
|
||||
|
|
@ -106,21 +81,27 @@ lp_build_sample_texel_soa(struct lp_build_sample_context *bld,
|
|||
LLVMValueRef data_ptr,
|
||||
LLVMValueRef texel_out[4])
|
||||
{
|
||||
const int dims = texture_dims(bld->static_state->target);
|
||||
const struct lp_sampler_static_state *static_state = bld->static_state;
|
||||
const int dims = texture_dims(static_state->target);
|
||||
struct lp_build_context *int_coord_bld = &bld->int_coord_bld;
|
||||
LLVMValueRef offset;
|
||||
LLVMValueRef i, j;
|
||||
LLVMValueRef use_border = NULL;
|
||||
|
||||
/* use_border = x < 0 || x >= width || y < 0 || y >= height */
|
||||
if (wrap_mode_uses_border_color(bld->static_state->wrap_s)) {
|
||||
if (lp_sampler_wrap_mode_uses_border_color(static_state->wrap_s,
|
||||
static_state->min_img_filter,
|
||||
static_state->mag_img_filter)) {
|
||||
LLVMValueRef b1, b2;
|
||||
b1 = lp_build_cmp(int_coord_bld, PIPE_FUNC_LESS, x, int_coord_bld->zero);
|
||||
b2 = lp_build_cmp(int_coord_bld, PIPE_FUNC_GEQUAL, x, width);
|
||||
use_border = LLVMBuildOr(bld->builder, b1, b2, "b1_or_b2");
|
||||
}
|
||||
|
||||
if (dims >= 2 && wrap_mode_uses_border_color(bld->static_state->wrap_t)) {
|
||||
if (dims >= 2 &&
|
||||
lp_sampler_wrap_mode_uses_border_color(static_state->wrap_t,
|
||||
static_state->min_img_filter,
|
||||
static_state->mag_img_filter)) {
|
||||
LLVMValueRef b1, b2;
|
||||
b1 = lp_build_cmp(int_coord_bld, PIPE_FUNC_LESS, y, int_coord_bld->zero);
|
||||
b2 = lp_build_cmp(int_coord_bld, PIPE_FUNC_GEQUAL, y, height);
|
||||
|
|
@ -133,7 +114,10 @@ lp_build_sample_texel_soa(struct lp_build_sample_context *bld,
|
|||
}
|
||||
}
|
||||
|
||||
if (dims == 3 && wrap_mode_uses_border_color(bld->static_state->wrap_r)) {
|
||||
if (dims == 3 &&
|
||||
lp_sampler_wrap_mode_uses_border_color(static_state->wrap_r,
|
||||
static_state->min_img_filter,
|
||||
static_state->mag_img_filter)) {
|
||||
LLVMValueRef b1, b2;
|
||||
b1 = lp_build_cmp(int_coord_bld, PIPE_FUNC_LESS, z, int_coord_bld->zero);
|
||||
b2 = lp_build_cmp(int_coord_bld, PIPE_FUNC_GEQUAL, z, depth);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue