gallium: add support for formatted image loads
[mesa.git] / src / gallium / drivers / nouveau / nv30 / nv30_texture.c
index d3cffcfb2619985762180cce293c9ab167b3fc25..358b3bbc32c514d98c579b4eb79431dc36ced9ab 100644 (file)
@@ -37,7 +37,7 @@
 #define NV40_WRAP(n) \
    case PIPE_TEX_WRAP_##n: ret = NV40_3D_TEX_WRAP_S_##n; break
 
-static INLINE unsigned
+static inline unsigned
 wrap_mode(unsigned pipe)
 {
    unsigned ret = NV30_3D_TEX_WRAP_S_REPEAT;
@@ -58,7 +58,7 @@ wrap_mode(unsigned pipe)
    return ret >> NV30_3D_TEX_WRAP_S__SHIFT;
 }
 
-static INLINE unsigned
+static inline unsigned
 filter_mode(const struct pipe_sampler_state *cso)
 {
    unsigned filter;
@@ -104,7 +104,7 @@ filter_mode(const struct pipe_sampler_state *cso)
    return filter;
 }
 
-static INLINE unsigned
+static inline unsigned
 compare_mode(const struct pipe_sampler_state *cso)
 {
    if (cso->compare_mode != PIPE_TEX_COMPARE_R_TO_TEXTURE)
@@ -186,11 +186,29 @@ nv30_sampler_state_delete(struct pipe_context *pipe, void *hwcso)
    FREE(hwcso);
 }
 
-static INLINE uint32_t
+static void
+nv30_bind_sampler_states(struct pipe_context *pipe,
+                         enum pipe_shader_type shader, unsigned start_slot,
+                         unsigned num_samplers, void **samplers)
+{
+   switch (shader) {
+   case PIPE_SHADER_VERTEX:
+      nv40_verttex_sampler_states_bind(pipe, num_samplers, samplers);
+      break;
+   case PIPE_SHADER_FRAGMENT:
+      nv30_fragtex_sampler_states_bind(pipe, num_samplers, samplers);
+      break;
+   default:
+      assert(!"unexpected shader type");
+      break;
+   }
+}
+
+static inline uint32_t
 swizzle(const struct nv30_texfmt *fmt, unsigned cmp, unsigned swz)
 {
    uint32_t data = fmt->swz[swz].src << 8;
-   if (swz <= PIPE_SWIZZLE_ALPHA)
+   if (swz <= PIPE_SWIZZLE_W)
       data |= fmt->swz[swz].cmp;
    else
       data |= fmt->swz[cmp].cmp;
@@ -269,7 +287,7 @@ nv30_sampler_view_create(struct pipe_context *pipe, struct pipe_resource *pt,
    so->npot_size0 = (pt->width0 << 16) | pt->height0;
    if (eng3d->oclass >= NV40_3D_CLASS) {
       so->npot_size1 = (pt->depth0 << 20) | mt->uniform_pitch;
-      if (!mt->swizzled)
+      if (mt->uniform_pitch)
          so->fmt |= NV40_3D_TEX_FORMAT_LINEAR;
       so->fmt |= 0x00008000;
       so->fmt |= (pt->last_level + 1) << NV40_3D_TEX_FORMAT_MIPMAP_COUNT__SHIFT;
@@ -301,6 +319,8 @@ nv30_texture_init(struct pipe_context *pipe)
 {
    pipe->create_sampler_state = nv30_sampler_state_create;
    pipe->delete_sampler_state = nv30_sampler_state_delete;
+   pipe->bind_sampler_states = nv30_bind_sampler_states;
+
    pipe->create_sampler_view = nv30_sampler_view_create;
    pipe->sampler_view_destroy = nv30_sampler_view_destroy;
 }