summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gallium/drivers/nv50/nv50_state.c2
-rw-r--r--src/gallium/drivers/nv50/nv50_stateobj.h25
-rw-r--r--src/gallium/drivers/nv50/nv50_stateobj_tex.h34
-rw-r--r--src/gallium/drivers/nv50/nv50_tex.c1
-rw-r--r--src/gallium/drivers/nvc0/nvc0_context.h2
-rw-r--r--src/gallium/drivers/nvc0/nvc0_screen.c4
-rw-r--r--src/gallium/drivers/nvc0/nvc0_screen.h8
-rw-r--r--src/gallium/drivers/nvc0/nvc0_state.c100
-rw-r--r--src/gallium/drivers/nvc0/nvc0_stateobj.h25
-rw-r--r--src/gallium/drivers/nvc0/nvc0_tex.c9
10 files changed, 60 insertions, 150 deletions
diff --git a/src/gallium/drivers/nv50/nv50_state.c b/src/gallium/drivers/nv50/nv50_state.c
index 3d6423b2238..980bc369293 100644
--- a/src/gallium/drivers/nv50/nv50_state.c
+++ b/src/gallium/drivers/nv50/nv50_state.c
@@ -380,7 +380,7 @@ nv50_tsc_wrap_mode(unsigned wrap)
}
}
-static void *
+void *
nv50_sampler_state_create(struct pipe_context *pipe,
const struct pipe_sampler_state *cso)
{
diff --git a/src/gallium/drivers/nv50/nv50_stateobj.h b/src/gallium/drivers/nv50/nv50_stateobj.h
index f4e458b0c05..cf5b92ef1a8 100644
--- a/src/gallium/drivers/nv50/nv50_stateobj.h
+++ b/src/gallium/drivers/nv50/nv50_stateobj.h
@@ -16,35 +16,14 @@
#define SB_DATA(so, u) (so)->state[(so)->size++] = (u)
+#include "nv50_stateobj_tex.h"
+
struct nv50_blend_stateobj {
struct pipe_blend_state pipe;
int size;
uint32_t state[78];
};
-struct nv50_tsc_entry {
- int id;
- uint32_t tsc[8];
-};
-
-static INLINE struct nv50_tsc_entry *
-nv50_tsc_entry(void *hwcso)
-{
- return (struct nv50_tsc_entry *)hwcso;
-}
-
-struct nv50_tic_entry {
- struct pipe_sampler_view pipe;
- int id;
- uint32_t tic[8];
-};
-
-static INLINE struct nv50_tic_entry *
-nv50_tic_entry(struct pipe_sampler_view *view)
-{
- return (struct nv50_tic_entry *)view;
-}
-
struct nv50_rasterizer_stateobj {
struct pipe_rasterizer_state pipe;
int size;
diff --git a/src/gallium/drivers/nv50/nv50_stateobj_tex.h b/src/gallium/drivers/nv50/nv50_stateobj_tex.h
new file mode 100644
index 00000000000..99548cbdb42
--- /dev/null
+++ b/src/gallium/drivers/nv50/nv50_stateobj_tex.h
@@ -0,0 +1,34 @@
+
+#ifndef __NV50_STATEOBJ_TEX_H__
+#define __NV50_STATEOBJ_TEX_H__
+
+#include "pipe/p_state.h"
+
+struct nv50_tsc_entry {
+ int id;
+ uint32_t tsc[8];
+};
+
+static INLINE struct nv50_tsc_entry *
+nv50_tsc_entry(void *hwcso)
+{
+ return (struct nv50_tsc_entry *)hwcso;
+}
+
+struct nv50_tic_entry {
+ struct pipe_sampler_view pipe;
+ int id;
+ uint32_t tic[8];
+};
+
+static INLINE struct nv50_tic_entry *
+nv50_tic_entry(struct pipe_sampler_view *view)
+{
+ return (struct nv50_tic_entry *)view;
+}
+
+extern void *
+nv50_sampler_state_create(struct pipe_context *,
+ const struct pipe_sampler_state *);
+
+#endif /* __NV50_STATEOBJ_TEX_H__ */
diff --git a/src/gallium/drivers/nv50/nv50_tex.c b/src/gallium/drivers/nv50/nv50_tex.c
index cb1f2620786..e9d6e5f2016 100644
--- a/src/gallium/drivers/nv50/nv50_tex.c
+++ b/src/gallium/drivers/nv50/nv50_tex.c
@@ -148,6 +148,7 @@ nv50_create_sampler_view(struct pipe_context *pipe,
break;
case PIPE_BUFFER:
tic[2] |= NV50_TIC_2_TARGET_BUFFER | NV50_TIC_2_LINEAR;
+ break;
default:
NOUVEAU_ERR("invalid texture target: %d\n", mt->base.base.target);
return FALSE;
diff --git a/src/gallium/drivers/nvc0/nvc0_context.h b/src/gallium/drivers/nvc0/nvc0_context.h
index 114e664fc58..67c5a1287b1 100644
--- a/src/gallium/drivers/nvc0/nvc0_context.h
+++ b/src/gallium/drivers/nvc0/nvc0_context.h
@@ -112,7 +112,7 @@ struct nvc0_context {
struct pipe_sampler_view *textures[5][PIPE_MAX_SAMPLERS];
unsigned num_textures[5];
- struct nvc0_tsc_entry *samplers[5][PIPE_MAX_SAMPLERS];
+ struct nv50_tsc_entry *samplers[5][PIPE_MAX_SAMPLERS];
unsigned num_samplers[5];
struct pipe_framebuffer_state framebuffer;
diff --git a/src/gallium/drivers/nvc0/nvc0_screen.c b/src/gallium/drivers/nvc0/nvc0_screen.c
index bf4e796adf5..d430be92c51 100644
--- a/src/gallium/drivers/nvc0/nvc0_screen.c
+++ b/src/gallium/drivers/nvc0/nvc0_screen.c
@@ -651,7 +651,7 @@ nvc0_screen_tic_alloc(struct nvc0_screen *screen, void *entry)
screen->tic.next = (i + 1) & (NVC0_TIC_MAX_ENTRIES - 1);
if (screen->tic.entries[i])
- nvc0_tic_entry(screen->tic.entries[i])->id = -1;
+ nv50_tic_entry(screen->tic.entries[i])->id = -1;
screen->tic.entries[i] = entry;
return i;
@@ -668,7 +668,7 @@ nvc0_screen_tsc_alloc(struct nvc0_screen *screen, void *entry)
screen->tsc.next = (i + 1) & (NVC0_TSC_MAX_ENTRIES - 1);
if (screen->tsc.entries[i])
- nvc0_tsc_entry(screen->tsc.entries[i])->id = -1;
+ nv50_tsc_entry(screen->tsc.entries[i])->id = -1;
screen->tsc.entries[i] = entry;
return i;
diff --git a/src/gallium/drivers/nvc0/nvc0_screen.h b/src/gallium/drivers/nvc0/nvc0_screen.h
index d8b8c5e3dc8..81f404ada83 100644
--- a/src/gallium/drivers/nvc0/nvc0_screen.h
+++ b/src/gallium/drivers/nvc0/nvc0_screen.h
@@ -114,21 +114,21 @@ struct nvc0_format {
extern const struct nvc0_format nvc0_format_table[];
static INLINE void
-nvc0_screen_tic_unlock(struct nvc0_screen *screen, struct nvc0_tic_entry *tic)
+nvc0_screen_tic_unlock(struct nvc0_screen *screen, struct nv50_tic_entry *tic)
{
if (tic->id >= 0)
screen->tic.lock[tic->id / 32] &= ~(1 << (tic->id % 32));
}
static INLINE void
-nvc0_screen_tsc_unlock(struct nvc0_screen *screen, struct nvc0_tsc_entry *tsc)
+nvc0_screen_tsc_unlock(struct nvc0_screen *screen, struct nv50_tsc_entry *tsc)
{
if (tsc->id >= 0)
screen->tsc.lock[tsc->id / 32] &= ~(1 << (tsc->id % 32));
}
static INLINE void
-nvc0_screen_tic_free(struct nvc0_screen *screen, struct nvc0_tic_entry *tic)
+nvc0_screen_tic_free(struct nvc0_screen *screen, struct nv50_tic_entry *tic)
{
if (tic->id >= 0) {
screen->tic.entries[tic->id] = NULL;
@@ -137,7 +137,7 @@ nvc0_screen_tic_free(struct nvc0_screen *screen, struct nvc0_tic_entry *tic)
}
static INLINE void
-nvc0_screen_tsc_free(struct nvc0_screen *screen, struct nvc0_tsc_entry *tsc)
+nvc0_screen_tsc_free(struct nvc0_screen *screen, struct nv50_tsc_entry *tsc)
{
if (tsc->id >= 0) {
screen->tsc.entries[tsc->id] = NULL;
diff --git a/src/gallium/drivers/nvc0/nvc0_state.c b/src/gallium/drivers/nvc0/nvc0_state.c
index 69af3338264..f230292316f 100644
--- a/src/gallium/drivers/nvc0/nvc0_state.c
+++ b/src/gallium/drivers/nvc0/nvc0_state.c
@@ -361,90 +361,6 @@ nv50_tsc_wrap_mode(unsigned wrap)
}
}
-static void *
-nvc0_sampler_state_create(struct pipe_context *pipe,
- const struct pipe_sampler_state *cso)
-{
- struct nvc0_tsc_entry *so = CALLOC_STRUCT(nvc0_tsc_entry);
- float f[2];
-
- so->id = -1;
-
- so->tsc[0] = (0x00026000 |
- (nv50_tsc_wrap_mode(cso->wrap_s) << 0) |
- (nv50_tsc_wrap_mode(cso->wrap_t) << 3) |
- (nv50_tsc_wrap_mode(cso->wrap_r) << 6));
-
- switch (cso->mag_img_filter) {
- case PIPE_TEX_FILTER_LINEAR:
- so->tsc[1] |= NV50_TSC_1_MAGF_LINEAR;
- break;
- case PIPE_TEX_FILTER_NEAREST:
- default:
- so->tsc[1] |= NV50_TSC_1_MAGF_NEAREST;
- break;
- }
-
- switch (cso->min_img_filter) {
- case PIPE_TEX_FILTER_LINEAR:
- so->tsc[1] |= NV50_TSC_1_MINF_LINEAR;
- break;
- case PIPE_TEX_FILTER_NEAREST:
- default:
- so->tsc[1] |= NV50_TSC_1_MINF_NEAREST;
- break;
- }
-
- switch (cso->min_mip_filter) {
- case PIPE_TEX_MIPFILTER_LINEAR:
- so->tsc[1] |= NV50_TSC_1_MIPF_LINEAR;
- break;
- case PIPE_TEX_MIPFILTER_NEAREST:
- so->tsc[1] |= NV50_TSC_1_MIPF_NEAREST;
- break;
- case PIPE_TEX_MIPFILTER_NONE:
- default:
- so->tsc[1] |= NV50_TSC_1_MIPF_NONE;
- break;
- }
-
- if (cso->max_anisotropy >= 16)
- so->tsc[0] |= (7 << 20);
- else
- if (cso->max_anisotropy >= 12)
- so->tsc[0] |= (6 << 20);
- else {
- so->tsc[0] |= (cso->max_anisotropy >> 1) << 20;
-
- if (cso->max_anisotropy >= 4)
- so->tsc[1] |= NV50_TSC_1_UNKN_ANISO_35;
- else
- if (cso->max_anisotropy >= 2)
- so->tsc[1] |= NV50_TSC_1_UNKN_ANISO_15;
- }
-
- if (cso->compare_mode == PIPE_TEX_COMPARE_R_TO_TEXTURE) {
- /* NOTE: must be deactivated for non-shadow textures */
- so->tsc[0] |= (1 << 9);
- so->tsc[0] |= (nvgl_comparison_op(cso->compare_func) & 0x7) << 10;
- }
-
- f[0] = CLAMP(cso->lod_bias, -16.0f, 15.0f);
- so->tsc[1] |= ((int)(f[0] * 256.0f) & 0x1fff) << 12;
-
- f[0] = CLAMP(cso->min_lod, 0.0f, 15.0f);
- f[1] = CLAMP(cso->max_lod, 0.0f, 15.0f);
- 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]);
-
- return (void *)so;
-}
-
static void
nvc0_sampler_state_delete(struct pipe_context *pipe, void *hwcso)
{
@@ -455,7 +371,7 @@ nvc0_sampler_state_delete(struct pipe_context *pipe, void *hwcso)
if (nvc0_context(pipe)->samplers[s][i] == hwcso)
nvc0_context(pipe)->samplers[s][i] = NULL;
- nvc0_screen_tsc_free(nvc0_context(pipe)->screen, nvc0_tsc_entry(hwcso));
+ nvc0_screen_tsc_free(nvc0_context(pipe)->screen, nv50_tsc_entry(hwcso));
FREE(hwcso);
}
@@ -467,9 +383,9 @@ nvc0_stage_sampler_states_bind(struct nvc0_context *nvc0, int s,
unsigned i;
for (i = 0; i < nr; ++i) {
- struct nvc0_tsc_entry *old = nvc0->samplers[s][i];
+ struct nv50_tsc_entry *old = nvc0->samplers[s][i];
- nvc0->samplers[s][i] = nvc0_tsc_entry(hwcso[i]);
+ nvc0->samplers[s][i] = nv50_tsc_entry(hwcso[i]);
if (old)
nvc0_screen_tsc_unlock(nvc0->screen, old);
}
@@ -507,9 +423,9 @@ nvc0_sampler_view_destroy(struct pipe_context *pipe,
{
pipe_resource_reference(&view->texture, NULL);
- nvc0_screen_tic_free(nvc0_context(pipe)->screen, nvc0_tic_entry(view));
+ nvc0_screen_tic_free(nvc0_context(pipe)->screen, nv50_tic_entry(view));
- FREE(nvc0_tic_entry(view));
+ FREE(nv50_tic_entry(view));
}
static INLINE void
@@ -520,7 +436,7 @@ nvc0_stage_set_sampler_views(struct nvc0_context *nvc0, int s,
unsigned i;
for (i = 0; i < nr; ++i) {
- struct nvc0_tic_entry *old = nvc0_tic_entry(nvc0->textures[s][i]);
+ struct nv50_tic_entry *old = nv50_tic_entry(nvc0->textures[s][i]);
if (old)
nvc0_screen_tic_unlock(nvc0->screen, old);
@@ -528,7 +444,7 @@ nvc0_stage_set_sampler_views(struct nvc0_context *nvc0, int s,
}
for (i = nr; i < nvc0->num_textures[s]; ++i) {
- struct nvc0_tic_entry *old = nvc0_tic_entry(nvc0->textures[s][i]);
+ struct nv50_tic_entry *old = nv50_tic_entry(nvc0->textures[s][i]);
if (!old)
continue;
nvc0_screen_tic_unlock(nvc0->screen, old);
@@ -890,7 +806,7 @@ nvc0_init_state_functions(struct nvc0_context *nvc0)
pipe->bind_depth_stencil_alpha_state = nvc0_zsa_state_bind;
pipe->delete_depth_stencil_alpha_state = nvc0_zsa_state_delete;
- pipe->create_sampler_state = nvc0_sampler_state_create;
+ pipe->create_sampler_state = nv50_sampler_state_create;
pipe->delete_sampler_state = nvc0_sampler_state_delete;
pipe->bind_vertex_sampler_states = nvc0_vp_sampler_states_bind;
pipe->bind_fragment_sampler_states = nvc0_fp_sampler_states_bind;
diff --git a/src/gallium/drivers/nvc0/nvc0_stateobj.h b/src/gallium/drivers/nvc0/nvc0_stateobj.h
index c0c77a2ee18..8222f9375ee 100644
--- a/src/gallium/drivers/nvc0/nvc0_stateobj.h
+++ b/src/gallium/drivers/nvc0/nvc0_stateobj.h
@@ -14,35 +14,14 @@
#define SB_DATA(so, u) (so)->state[(so)->size++] = (u)
+#include "nv50/nv50_stateobj_tex.h"
+
struct nvc0_blend_stateobj {
struct pipe_blend_state pipe;
int size;
uint32_t state[72];
};
-struct nvc0_tsc_entry {
- int id;
- uint32_t tsc[8];
-};
-
-static INLINE struct nvc0_tsc_entry *
-nvc0_tsc_entry(void *hwcso)
-{
- return (struct nvc0_tsc_entry *)hwcso;
-}
-
-struct nvc0_tic_entry {
- struct pipe_sampler_view pipe;
- int id;
- uint32_t tic[8]; /* tic[1] (low 32 bit of address) is used for offset */
-};
-
-static INLINE struct nvc0_tic_entry *
-nvc0_tic_entry(struct pipe_sampler_view *view)
-{
- return (struct nvc0_tic_entry *)view;
-}
-
struct nvc0_rasterizer_stateobj {
struct pipe_rasterizer_state pipe;
int size;
diff --git a/src/gallium/drivers/nvc0/nvc0_tex.c b/src/gallium/drivers/nvc0/nvc0_tex.c
index 7446be67092..a6f393d1ecc 100644
--- a/src/gallium/drivers/nvc0/nvc0_tex.c
+++ b/src/gallium/drivers/nvc0/nvc0_tex.c
@@ -59,11 +59,11 @@ nvc0_create_sampler_view(struct pipe_context *pipe,
uint32_t *tic;
uint32_t swz[4];
uint32_t depth;
- struct nvc0_tic_entry *view;
+ struct nv50_tic_entry *view;
struct nvc0_miptree *mt = nvc0_miptree(texture);
boolean tex_int;
- view = MALLOC_STRUCT(nvc0_tic_entry);
+ view = MALLOC_STRUCT(nv50_tic_entry);
if (!view)
return NULL;
@@ -148,6 +148,7 @@ nvc0_create_sampler_view(struct pipe_context *pipe,
break;
case PIPE_BUFFER:
tic[2] |= NV50_TIC_2_TARGET_BUFFER | NV50_TIC_2_LINEAR;
+ break;
default:
NOUVEAU_ERR("invalid texture target: %d\n", mt->base.base.target);
return FALSE;
@@ -180,7 +181,7 @@ nvc0_validate_tic(struct nvc0_context *nvc0, int s)
boolean need_flush = FALSE;
for (i = 0; i < nvc0->num_textures[s]; ++i) {
- struct nvc0_tic_entry *tic = nvc0_tic_entry(nvc0->textures[s][i]);
+ struct nv50_tic_entry *tic = nv50_tic_entry(nvc0->textures[s][i]);
struct nv04_resource *res;
if (!tic) {
@@ -258,7 +259,7 @@ nvc0_validate_tsc(struct nvc0_context *nvc0, int s)
boolean need_flush = FALSE;
for (i = 0; i < nvc0->num_samplers[s]; ++i) {
- struct nvc0_tsc_entry *tsc = nvc0_tsc_entry(nvc0->samplers[s][i]);
+ struct nv50_tsc_entry *tsc = nv50_tsc_entry(nvc0->samplers[s][i]);
if (!tsc) {
BEGIN_RING(chan, RING_3D(BIND_TSC(s)), 1);