softpipe: don't use samplers with prebaked sampler and sampler_view state
This is needed for handling the dx10-style sample opcodes. This also simplifies the logic by getting rid of sampler variants completely (sampler_views though OTOH have sort of variants because some of their state is different depending on the shader stage they are bound to). No significant performance difference (openarena run: 840 frames in 459.8 seconds vs. 840 frames in 460.5 seconds). v2: fix reference counting bug spotted by Jose. Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
This commit is contained in:
parent
f33c744fb9
commit
ef17cc9cb6
|
@ -80,7 +80,7 @@ struct softpipe_context {
|
||||||
struct pipe_framebuffer_state framebuffer;
|
struct pipe_framebuffer_state framebuffer;
|
||||||
struct pipe_poly_stipple poly_stipple;
|
struct pipe_poly_stipple poly_stipple;
|
||||||
struct pipe_scissor_state scissor;
|
struct pipe_scissor_state scissor;
|
||||||
struct pipe_sampler_view *sampler_views[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS];
|
struct pipe_sampler_view *sampler_views[PIPE_SHADER_TYPES][PIPE_MAX_SHADER_SAMPLER_VIEWS];
|
||||||
|
|
||||||
struct pipe_viewport_state viewport;
|
struct pipe_viewport_state viewport;
|
||||||
struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];
|
struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];
|
||||||
|
@ -184,8 +184,10 @@ struct softpipe_context {
|
||||||
* Texture caches for vertex, fragment, geometry stages.
|
* Texture caches for vertex, fragment, geometry stages.
|
||||||
* Don't use PIPE_SHADER_TYPES here to avoid allocating unused memory
|
* Don't use PIPE_SHADER_TYPES here to avoid allocating unused memory
|
||||||
* for compute shaders.
|
* for compute shaders.
|
||||||
|
* XXX wouldn't it make more sense for the tile cache to just be part
|
||||||
|
* of sp_sampler_view?
|
||||||
*/
|
*/
|
||||||
struct softpipe_tex_tile_cache *tex_cache[PIPE_SHADER_GEOMETRY+1][PIPE_MAX_SAMPLERS];
|
struct softpipe_tex_tile_cache *tex_cache[PIPE_SHADER_GEOMETRY+1][PIPE_MAX_SHADER_SAMPLER_VIEWS];
|
||||||
|
|
||||||
unsigned dump_fs : 1;
|
unsigned dump_fs : 1;
|
||||||
unsigned dump_gs : 1;
|
unsigned dump_gs : 1;
|
||||||
|
@ -199,8 +201,6 @@ softpipe_context( struct pipe_context *pipe )
|
||||||
return (struct softpipe_context *)pipe;
|
return (struct softpipe_context *)pipe;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
softpipe_reset_sampler_variants(struct softpipe_context *softpipe);
|
|
||||||
|
|
||||||
struct pipe_context *
|
struct pipe_context *
|
||||||
softpipe_create_context( struct pipe_screen *, void *priv );
|
softpipe_create_context( struct pipe_screen *, void *priv );
|
||||||
|
|
|
@ -155,6 +155,14 @@ softpipe_set_framebuffer_state(struct pipe_context *,
|
||||||
void
|
void
|
||||||
softpipe_update_derived(struct softpipe_context *softpipe, unsigned prim);
|
softpipe_update_derived(struct softpipe_context *softpipe, unsigned prim);
|
||||||
|
|
||||||
|
void
|
||||||
|
softpipe_set_sampler_views(struct pipe_context *pipe,
|
||||||
|
unsigned shader,
|
||||||
|
unsigned start,
|
||||||
|
unsigned num,
|
||||||
|
struct pipe_sampler_view **views);
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
softpipe_draw_vbo(struct pipe_context *pipe,
|
softpipe_draw_vbo(struct pipe_context *pipe,
|
||||||
const struct pipe_draw_info *info);
|
const struct pipe_draw_info *info);
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include "sp_screen.h"
|
#include "sp_screen.h"
|
||||||
#include "sp_state.h"
|
#include "sp_state.h"
|
||||||
#include "sp_texture.h"
|
#include "sp_texture.h"
|
||||||
|
#include "sp_tex_sample.h"
|
||||||
#include "sp_tex_tile_cache.h"
|
#include "sp_tex_tile_cache.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -204,13 +205,33 @@ compute_cliprect(struct softpipe_context *sp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
set_shader_sampler(struct softpipe_context *softpipe,
|
||||||
|
unsigned shader,
|
||||||
|
int max_sampler)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i = 0; i <= max_sampler; i++) {
|
||||||
|
softpipe->tgsi.sampler[shader]->sp_sampler[i] =
|
||||||
|
(struct sp_sampler *)(softpipe->samplers[shader][i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
update_tgsi_samplers( struct softpipe_context *softpipe )
|
update_tgsi_samplers( struct softpipe_context *softpipe )
|
||||||
{
|
{
|
||||||
unsigned i, sh;
|
unsigned i, sh;
|
||||||
|
|
||||||
softpipe_reset_sampler_variants( softpipe );
|
set_shader_sampler(softpipe, PIPE_SHADER_VERTEX,
|
||||||
|
softpipe->vs->max_sampler);
|
||||||
|
set_shader_sampler(softpipe, PIPE_SHADER_FRAGMENT,
|
||||||
|
softpipe->fs_variant->info.file_max[TGSI_FILE_SAMPLER]);
|
||||||
|
if (softpipe->gs) {
|
||||||
|
set_shader_sampler(softpipe, PIPE_SHADER_GEOMETRY,
|
||||||
|
softpipe->gs->max_sampler);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* XXX is this really necessary here??? */
|
||||||
for (sh = 0; sh < Elements(softpipe->tex_cache); sh++) {
|
for (sh = 0; sh < Elements(softpipe->tex_cache); sh++) {
|
||||||
for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
|
for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
|
||||||
struct softpipe_tex_tile_cache *tc = softpipe->tex_cache[sh][i];
|
struct softpipe_tex_tile_cache *tc = softpipe->tex_cache[sh][i];
|
||||||
|
@ -314,12 +335,9 @@ update_polygon_stipple_enable(struct softpipe_context *softpipe, unsigned prim)
|
||||||
/* sampler state */
|
/* sampler state */
|
||||||
softpipe->samplers[PIPE_SHADER_FRAGMENT][unit] = softpipe->pstipple.sampler;
|
softpipe->samplers[PIPE_SHADER_FRAGMENT][unit] = softpipe->pstipple.sampler;
|
||||||
|
|
||||||
/* sampler view */
|
/* sampler view state */
|
||||||
pipe_sampler_view_reference(&softpipe->sampler_views[PIPE_SHADER_FRAGMENT][unit],
|
softpipe_set_sampler_views(&softpipe->pipe, PIPE_SHADER_FRAGMENT,
|
||||||
softpipe->pstipple.sampler_view);
|
unit, 1, &softpipe->pstipple.sampler_view);
|
||||||
|
|
||||||
sp_tex_tile_cache_set_sampler_view(softpipe->tex_cache[PIPE_SHADER_FRAGMENT][unit],
|
|
||||||
softpipe->pstipple.sampler_view);
|
|
||||||
|
|
||||||
softpipe->dirty |= SP_NEW_SAMPLER;
|
softpipe->dirty |= SP_NEW_SAMPLER;
|
||||||
}
|
}
|
||||||
|
@ -358,6 +376,7 @@ softpipe_update_derived(struct softpipe_context *softpipe, unsigned prim)
|
||||||
update_polygon_stipple_enable(softpipe, prim);
|
update_polygon_stipple_enable(softpipe, prim);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* TODO: this looks suboptimal */
|
||||||
if (softpipe->dirty & (SP_NEW_SAMPLER |
|
if (softpipe->dirty & (SP_NEW_SAMPLER |
|
||||||
SP_NEW_TEXTURE |
|
SP_NEW_TEXTURE |
|
||||||
SP_NEW_FS |
|
SP_NEW_FS |
|
||||||
|
|
|
@ -41,31 +41,6 @@
|
||||||
#include "sp_tex_tile_cache.h"
|
#include "sp_tex_tile_cache.h"
|
||||||
|
|
||||||
|
|
||||||
struct sp_sampler {
|
|
||||||
struct pipe_sampler_state base;
|
|
||||||
struct sp_sampler_variant *variants;
|
|
||||||
struct sp_sampler_variant *current;
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct sp_sampler *sp_sampler( struct pipe_sampler_state *sampler )
|
|
||||||
{
|
|
||||||
return (struct sp_sampler *)sampler;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void *
|
|
||||||
softpipe_create_sampler_state(struct pipe_context *pipe,
|
|
||||||
const struct pipe_sampler_state *sampler)
|
|
||||||
{
|
|
||||||
struct sp_sampler *sp_sampler = CALLOC_STRUCT(sp_sampler);
|
|
||||||
|
|
||||||
sp_sampler->base = *sampler;
|
|
||||||
sp_sampler->variants = NULL;
|
|
||||||
|
|
||||||
return (void *)sp_sampler;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bind a range [start, start+num-1] of samplers for a shader stage.
|
* Bind a range [start, start+num-1] of samplers for a shader stage.
|
||||||
*/
|
*/
|
||||||
|
@ -142,24 +117,6 @@ softpipe_bind_geometry_sampler_states(struct pipe_context *pipe,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static struct pipe_sampler_view *
|
|
||||||
softpipe_create_sampler_view(struct pipe_context *pipe,
|
|
||||||
struct pipe_resource *resource,
|
|
||||||
const struct pipe_sampler_view *templ)
|
|
||||||
{
|
|
||||||
struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view);
|
|
||||||
|
|
||||||
if (view) {
|
|
||||||
*view = *templ;
|
|
||||||
view->reference.count = 1;
|
|
||||||
view->texture = NULL;
|
|
||||||
pipe_resource_reference(&view->texture, resource);
|
|
||||||
view->context = pipe;
|
|
||||||
}
|
|
||||||
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
softpipe_sampler_view_destroy(struct pipe_context *pipe,
|
softpipe_sampler_view_destroy(struct pipe_context *pipe,
|
||||||
|
@ -170,7 +127,7 @@ softpipe_sampler_view_destroy(struct pipe_context *pipe,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
void
|
||||||
softpipe_set_sampler_views(struct pipe_context *pipe,
|
softpipe_set_sampler_views(struct pipe_context *pipe,
|
||||||
unsigned shader,
|
unsigned shader,
|
||||||
unsigned start,
|
unsigned start,
|
||||||
|
@ -194,11 +151,28 @@ softpipe_set_sampler_views(struct pipe_context *pipe,
|
||||||
|
|
||||||
/* set the new sampler views */
|
/* set the new sampler views */
|
||||||
for (i = 0; i < num; i++) {
|
for (i = 0; i < num; i++) {
|
||||||
pipe_sampler_view_reference(&softpipe->sampler_views[shader][start + i],
|
struct sp_sampler_view *sp_sviewsrc;
|
||||||
views[i]);
|
struct sp_sampler_view *sp_sviewdst =
|
||||||
|
&softpipe->tgsi.sampler[shader]->sp_sview[start + i];
|
||||||
|
struct pipe_sampler_view **pview = &softpipe->sampler_views[shader][start + i];
|
||||||
|
pipe_sampler_view_reference(pview, views[i]);
|
||||||
sp_tex_tile_cache_set_sampler_view(softpipe->tex_cache[shader][start + i],
|
sp_tex_tile_cache_set_sampler_view(softpipe->tex_cache[shader][start + i],
|
||||||
views[i]);
|
views[i]);
|
||||||
|
/*
|
||||||
|
* We don't really have variants, however some bits are different per shader,
|
||||||
|
* so just copy?
|
||||||
|
*/
|
||||||
|
sp_sviewsrc = (struct sp_sampler_view *)*pview;
|
||||||
|
if (sp_sviewsrc) {
|
||||||
|
memcpy(sp_sviewdst, sp_sviewsrc, sizeof(*sp_sviewsrc));
|
||||||
|
sp_sviewdst->compute_lambda = softpipe_get_lambda_func(&sp_sviewdst->base, shader);
|
||||||
|
sp_sviewdst->cache = softpipe->tex_cache[shader][start + i];
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
memset(sp_sviewdst, 0, sizeof(*sp_sviewsrc));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* find highest non-null sampler_views[] entry */
|
/* find highest non-null sampler_views[] entry */
|
||||||
{
|
{
|
||||||
|
@ -246,128 +220,10 @@ softpipe_set_geometry_sampler_views(struct pipe_context *pipe,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Find/create an sp_sampler_variant object for sampling the given texture,
|
|
||||||
* sampler and tex unit.
|
|
||||||
*
|
|
||||||
* Note that the tex unit is significant. We can't re-use a sampler
|
|
||||||
* variant for multiple texture units because the sampler variant contains
|
|
||||||
* the texture object pointer. If the texture object pointer were stored
|
|
||||||
* somewhere outside the sampler variant, we could re-use samplers for
|
|
||||||
* multiple texture units.
|
|
||||||
*/
|
|
||||||
static struct sp_sampler_variant *
|
|
||||||
get_sampler_variant( unsigned unit,
|
|
||||||
struct sp_sampler *sampler,
|
|
||||||
struct pipe_sampler_view *view,
|
|
||||||
unsigned processor )
|
|
||||||
{
|
|
||||||
struct softpipe_resource *sp_texture = softpipe_resource(view->texture);
|
|
||||||
struct sp_sampler_variant *v = NULL;
|
|
||||||
union sp_sampler_key key;
|
|
||||||
|
|
||||||
/* if this fails, widen the key.unit field and update this assertion */
|
|
||||||
assert(PIPE_MAX_SAMPLERS <= 16);
|
|
||||||
|
|
||||||
key.bits.target = sp_texture->base.target;
|
|
||||||
key.bits.is_pot = sp_texture->pot;
|
|
||||||
key.bits.processor = processor;
|
|
||||||
key.bits.unit = unit;
|
|
||||||
key.bits.swizzle_r = view->swizzle_r;
|
|
||||||
key.bits.swizzle_g = view->swizzle_g;
|
|
||||||
key.bits.swizzle_b = view->swizzle_b;
|
|
||||||
key.bits.swizzle_a = view->swizzle_a;
|
|
||||||
key.bits.pad = 0;
|
|
||||||
|
|
||||||
if (sampler->current &&
|
|
||||||
key.value == sampler->current->key.value) {
|
|
||||||
v = sampler->current;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (v == NULL) {
|
|
||||||
for (v = sampler->variants; v; v = v->next)
|
|
||||||
if (v->key.value == key.value)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (v == NULL) {
|
|
||||||
v = sp_create_sampler_variant( &sampler->base, key );
|
|
||||||
v->next = sampler->variants;
|
|
||||||
sampler->variants = v;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sampler->current = v;
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reset the sampler variants for a shader stage (vert, frag, geom).
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
reset_sampler_variants(struct softpipe_context *softpipe,
|
|
||||||
unsigned shader,
|
|
||||||
unsigned tgsi_shader,
|
|
||||||
int max_sampler)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i <= max_sampler; i++) {
|
|
||||||
if (softpipe->samplers[shader][i]) {
|
|
||||||
softpipe->tgsi.sampler[shader]->sp_sampler[i] =
|
|
||||||
get_sampler_variant(i,
|
|
||||||
sp_sampler(softpipe->samplers[shader][i]),
|
|
||||||
softpipe->sampler_views[shader][i],
|
|
||||||
tgsi_shader);
|
|
||||||
|
|
||||||
sp_sampler_variant_bind_view(softpipe->tgsi.sampler[shader]->sp_sampler[i],
|
|
||||||
softpipe->tex_cache[shader][i],
|
|
||||||
softpipe->sampler_views[shader][i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
softpipe_reset_sampler_variants(struct softpipe_context *softpipe)
|
|
||||||
{
|
|
||||||
/* It's a bit hard to build these samplers ahead of time -- don't
|
|
||||||
* really know which samplers are going to be used for vertex and
|
|
||||||
* fragment programs.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* XXX note: PIPE_SHADER_x != TGSI_PROCESSOR_x (fix that someday) */
|
|
||||||
reset_sampler_variants(softpipe,
|
|
||||||
PIPE_SHADER_VERTEX,
|
|
||||||
TGSI_PROCESSOR_VERTEX,
|
|
||||||
softpipe->vs->max_sampler);
|
|
||||||
|
|
||||||
reset_sampler_variants(softpipe,
|
|
||||||
PIPE_SHADER_FRAGMENT,
|
|
||||||
TGSI_PROCESSOR_FRAGMENT,
|
|
||||||
softpipe->fs_variant->info.file_max[TGSI_FILE_SAMPLER]);
|
|
||||||
|
|
||||||
if (softpipe->gs) {
|
|
||||||
reset_sampler_variants(softpipe,
|
|
||||||
PIPE_SHADER_GEOMETRY,
|
|
||||||
TGSI_PROCESSOR_GEOMETRY,
|
|
||||||
softpipe->gs->max_sampler);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
softpipe_delete_sampler_state(struct pipe_context *pipe,
|
softpipe_delete_sampler_state(struct pipe_context *pipe,
|
||||||
void *sampler)
|
void *sampler)
|
||||||
{
|
{
|
||||||
struct sp_sampler *sp_sampler = (struct sp_sampler *)sampler;
|
|
||||||
struct sp_sampler_variant *v, *tmp;
|
|
||||||
|
|
||||||
for (v = sp_sampler->variants; v; v = tmp) {
|
|
||||||
tmp = v->next;
|
|
||||||
sp_sampler_variant_destroy(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
FREE( sampler );
|
FREE( sampler );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -32,7 +32,9 @@
|
||||||
|
|
||||||
#include "tgsi/tgsi_exec.h"
|
#include "tgsi/tgsi_exec.h"
|
||||||
|
|
||||||
struct sp_sampler_variant;
|
|
||||||
|
struct sp_sampler_view;
|
||||||
|
struct sp_sampler;
|
||||||
|
|
||||||
typedef void (*wrap_nearest_func)(float s,
|
typedef void (*wrap_nearest_func)(float s,
|
||||||
unsigned size,
|
unsigned size,
|
||||||
|
@ -44,12 +46,13 @@ typedef void (*wrap_linear_func)(float s,
|
||||||
int *icoord1,
|
int *icoord1,
|
||||||
float *w);
|
float *w);
|
||||||
|
|
||||||
typedef float (*compute_lambda_func)(const struct sp_sampler_variant *samp,
|
typedef float (*compute_lambda_func)(const struct sp_sampler_view *sp_sview,
|
||||||
const float s[TGSI_QUAD_SIZE],
|
const float s[TGSI_QUAD_SIZE],
|
||||||
const float t[TGSI_QUAD_SIZE],
|
const float t[TGSI_QUAD_SIZE],
|
||||||
const float p[TGSI_QUAD_SIZE]);
|
const float p[TGSI_QUAD_SIZE]);
|
||||||
|
|
||||||
typedef void (*img_filter_func)(struct sp_sampler_variant *samp,
|
typedef void (*img_filter_func)(struct sp_sampler_view *sp_sview,
|
||||||
|
struct sp_sampler *sp_samp,
|
||||||
float s,
|
float s,
|
||||||
float t,
|
float t,
|
||||||
float p,
|
float p,
|
||||||
|
@ -57,7 +60,10 @@ typedef void (*img_filter_func)(struct sp_sampler_variant *samp,
|
||||||
unsigned face_id,
|
unsigned face_id,
|
||||||
float *rgba);
|
float *rgba);
|
||||||
|
|
||||||
typedef void (*filter_func)(struct sp_sampler_variant *sp_samp,
|
typedef void (*mip_filter_func)(struct sp_sampler_view *sp_sview,
|
||||||
|
struct sp_sampler *sp_samp,
|
||||||
|
img_filter_func min_filter,
|
||||||
|
img_filter_func mag_filter,
|
||||||
const float s[TGSI_QUAD_SIZE],
|
const float s[TGSI_QUAD_SIZE],
|
||||||
const float t[TGSI_QUAD_SIZE],
|
const float t[TGSI_QUAD_SIZE],
|
||||||
const float p[TGSI_QUAD_SIZE],
|
const float p[TGSI_QUAD_SIZE],
|
||||||
|
@ -67,53 +73,55 @@ typedef void (*filter_func)(struct sp_sampler_variant *sp_samp,
|
||||||
float rgba[TGSI_NUM_CHANNELS][TGSI_QUAD_SIZE]);
|
float rgba[TGSI_NUM_CHANNELS][TGSI_QUAD_SIZE]);
|
||||||
|
|
||||||
|
|
||||||
typedef void (*get_dim_func)(struct sp_sampler_variant *sp_samp,
|
typedef void (*filter_func)(struct sp_sampler_view *sp_sview,
|
||||||
int level, int dims[4]);
|
struct sp_sampler *sp_samp,
|
||||||
|
const float s[TGSI_QUAD_SIZE],
|
||||||
|
const float t[TGSI_QUAD_SIZE],
|
||||||
|
const float p[TGSI_QUAD_SIZE],
|
||||||
|
const float c0[TGSI_QUAD_SIZE],
|
||||||
|
const float lod[TGSI_QUAD_SIZE],
|
||||||
|
enum tgsi_sampler_control control,
|
||||||
|
float rgba[TGSI_NUM_CHANNELS][TGSI_QUAD_SIZE]);
|
||||||
|
|
||||||
typedef void (*fetch_func)(struct sp_sampler_variant *sp_samp,
|
|
||||||
|
typedef void (*fetch_func)(struct sp_sampler_view *sp_sview,
|
||||||
const int i[TGSI_QUAD_SIZE],
|
const int i[TGSI_QUAD_SIZE],
|
||||||
const int j[TGSI_QUAD_SIZE], const int k[TGSI_QUAD_SIZE],
|
const int j[TGSI_QUAD_SIZE], const int k[TGSI_QUAD_SIZE],
|
||||||
const int lod[TGSI_QUAD_SIZE], const int8_t offset[3],
|
const int lod[TGSI_QUAD_SIZE], const int8_t offset[3],
|
||||||
float rgba[TGSI_NUM_CHANNELS][TGSI_QUAD_SIZE]);
|
float rgba[TGSI_NUM_CHANNELS][TGSI_QUAD_SIZE]);
|
||||||
|
|
||||||
|
|
||||||
union sp_sampler_key {
|
struct sp_sampler_view
|
||||||
struct {
|
|
||||||
unsigned target:5;
|
|
||||||
unsigned is_pot:1;
|
|
||||||
unsigned processor:2;
|
|
||||||
unsigned unit:4;
|
|
||||||
unsigned swizzle_r:3;
|
|
||||||
unsigned swizzle_g:3;
|
|
||||||
unsigned swizzle_b:3;
|
|
||||||
unsigned swizzle_a:3;
|
|
||||||
unsigned pad:8;
|
|
||||||
} bits;
|
|
||||||
unsigned value;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
struct sp_sampler_variant
|
|
||||||
{
|
{
|
||||||
union sp_sampler_key key;
|
struct pipe_sampler_view base;
|
||||||
|
|
||||||
/* The owner of this struct:
|
|
||||||
*/
|
|
||||||
const struct pipe_sampler_state *sampler;
|
|
||||||
|
|
||||||
|
|
||||||
/* Currently bound texture:
|
|
||||||
*/
|
|
||||||
const struct pipe_sampler_view *view;
|
|
||||||
struct softpipe_tex_tile_cache *cache;
|
|
||||||
|
|
||||||
/* For sp_get_samples_2d_linear_POT:
|
/* For sp_get_samples_2d_linear_POT:
|
||||||
*/
|
*/
|
||||||
unsigned xpot;
|
unsigned xpot;
|
||||||
unsigned ypot;
|
unsigned ypot;
|
||||||
|
|
||||||
|
boolean need_swizzle;
|
||||||
|
boolean pot2d;
|
||||||
|
|
||||||
|
filter_func get_samples;
|
||||||
|
|
||||||
|
/* this is just abusing the sampler_view object as local storage */
|
||||||
unsigned faces[TGSI_QUAD_SIZE];
|
unsigned faces[TGSI_QUAD_SIZE];
|
||||||
|
|
||||||
|
/* these are different per shader type */
|
||||||
|
struct softpipe_tex_tile_cache *cache;
|
||||||
|
compute_lambda_func compute_lambda;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct sp_sampler {
|
||||||
|
struct pipe_sampler_state base;
|
||||||
|
|
||||||
|
boolean min_mag_equal_repeat_linear;
|
||||||
|
boolean min_mag_equal;
|
||||||
|
unsigned min_img_filter;
|
||||||
|
|
||||||
wrap_nearest_func nearest_texcoord_s;
|
wrap_nearest_func nearest_texcoord_s;
|
||||||
wrap_nearest_func nearest_texcoord_t;
|
wrap_nearest_func nearest_texcoord_t;
|
||||||
wrap_nearest_func nearest_texcoord_p;
|
wrap_nearest_func nearest_texcoord_p;
|
||||||
|
@ -122,23 +130,7 @@ struct sp_sampler_variant
|
||||||
wrap_linear_func linear_texcoord_t;
|
wrap_linear_func linear_texcoord_t;
|
||||||
wrap_linear_func linear_texcoord_p;
|
wrap_linear_func linear_texcoord_p;
|
||||||
|
|
||||||
img_filter_func min_img_filter;
|
mip_filter_func mip_filter;
|
||||||
img_filter_func mag_img_filter;
|
|
||||||
|
|
||||||
compute_lambda_func compute_lambda;
|
|
||||||
|
|
||||||
filter_func mip_filter;
|
|
||||||
filter_func compare;
|
|
||||||
filter_func sample_target;
|
|
||||||
|
|
||||||
filter_func get_samples;
|
|
||||||
fetch_func get_texel;
|
|
||||||
get_dim_func get_dims;
|
|
||||||
|
|
||||||
|
|
||||||
/* Linked list:
|
|
||||||
*/
|
|
||||||
struct sp_sampler_variant *next;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -148,40 +140,24 @@ struct sp_sampler_variant
|
||||||
struct sp_tgsi_sampler
|
struct sp_tgsi_sampler
|
||||||
{
|
{
|
||||||
struct tgsi_sampler base; /**< base class */
|
struct tgsi_sampler base; /**< base class */
|
||||||
struct sp_sampler_variant *sp_sampler[PIPE_MAX_SAMPLERS];
|
struct sp_sampler *sp_sampler[PIPE_MAX_SAMPLERS];
|
||||||
|
struct sp_sampler_view sp_sview[PIPE_MAX_SHADER_SAMPLER_VIEWS];
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
compute_lambda_func
|
||||||
struct sp_sampler;
|
softpipe_get_lambda_func(const struct pipe_sampler_view *view, unsigned shader);
|
||||||
|
|
||||||
/* Create a sampler variant for a given set of non-orthogonal state. Currently the
|
|
||||||
*/
|
|
||||||
struct sp_sampler_variant *
|
|
||||||
sp_create_sampler_variant( const struct pipe_sampler_state *sampler,
|
|
||||||
const union sp_sampler_key key );
|
|
||||||
|
|
||||||
void sp_sampler_variant_bind_view( struct sp_sampler_variant *variant,
|
|
||||||
struct softpipe_tex_tile_cache *tex_cache,
|
|
||||||
const struct pipe_sampler_view *view );
|
|
||||||
|
|
||||||
void sp_sampler_variant_destroy( struct sp_sampler_variant * );
|
|
||||||
|
|
||||||
|
|
||||||
|
void *
|
||||||
|
softpipe_create_sampler_state(struct pipe_context *pipe,
|
||||||
|
const struct pipe_sampler_state *sampler);
|
||||||
|
|
||||||
static INLINE struct sp_sampler_variant *
|
|
||||||
sp_sampler_variant(const struct tgsi_sampler *sampler)
|
|
||||||
{
|
|
||||||
return (struct sp_sampler_variant *) sampler;
|
|
||||||
}
|
|
||||||
|
|
||||||
extern void
|
struct pipe_sampler_view *
|
||||||
sp_get_samples(struct tgsi_sampler *tgsi_sampler,
|
softpipe_create_sampler_view(struct pipe_context *pipe,
|
||||||
const float s[TGSI_QUAD_SIZE],
|
struct pipe_resource *resource,
|
||||||
const float t[TGSI_QUAD_SIZE],
|
const struct pipe_sampler_view *templ);
|
||||||
const float p[TGSI_QUAD_SIZE],
|
|
||||||
float lodbias,
|
|
||||||
float rgba[TGSI_NUM_CHANNELS][TGSI_QUAD_SIZE]);
|
|
||||||
|
|
||||||
|
|
||||||
struct sp_tgsi_sampler *
|
struct sp_tgsi_sampler *
|
||||||
|
|
Loading…
Reference in New Issue