[g3dvl] move zscan into shaders
[mesa.git] / src / gallium / drivers / galahad / glhd_context.c
index ff6d2aa00ab694533caadc11e4891a5defac5369..f73d8a5d32e6d8fc61fba8194aca0fa6e226f9be 100644 (file)
@@ -381,6 +381,8 @@ galahad_create_vertex_elements_state(struct pipe_context *_pipe,
    struct galahad_context *glhd_pipe = galahad_context(_pipe);
    struct pipe_context *pipe = glhd_pipe->pipe;
 
+   /* XXX check if stride lines up with element size, at least for floats */
+
    return pipe->create_vertex_elements_state(pipe,
                                              num_elements,
                                              vertex_elements);
@@ -641,7 +643,7 @@ galahad_set_index_buffer(struct pipe_context *_pipe,
          break;
       default:
          glhd_warn("index buffer %p has unrecognized index size %d",
-               _ib->buffer, _ib->index_size);
+                   (void *) _ib->buffer, _ib->index_size);
          break;
       }
    }
@@ -662,17 +664,13 @@ galahad_set_index_buffer(struct pipe_context *_pipe,
 static void
 galahad_resource_copy_region(struct pipe_context *_pipe,
                               struct pipe_resource *_dst,
-                              struct pipe_subresource subdst,
+                              unsigned dst_level,
                               unsigned dstx,
                               unsigned dsty,
                               unsigned dstz,
                               struct pipe_resource *_src,
-                              struct pipe_subresource subsrc,
-                              unsigned srcx,
-                              unsigned srcy,
-                              unsigned srcz,
-                              unsigned width,
-                              unsigned height)
+                              unsigned src_level,
+                              const struct pipe_box *src_box)
 {
    struct galahad_context *glhd_pipe = galahad_context(_pipe);
    struct galahad_resource *glhd_resource_dst = galahad_resource(_dst);
@@ -687,19 +685,21 @@ galahad_resource_copy_region(struct pipe_context *_pipe,
          util_format_short_name(_dst->format));
    }
 
+   if ((_src->target == PIPE_BUFFER && _dst->target != PIPE_BUFFER) ||
+       (_src->target != PIPE_BUFFER && _dst->target == PIPE_BUFFER)) {
+      glhd_warn("Resource target mismatch: Source is %i, destination is %i",
+                _src->target, _dst->target);
+   }
+
    pipe->resource_copy_region(pipe,
                               dst,
-                              subdst,
+                              dst_level,
                               dstx,
                               dsty,
                               dstz,
                               src,
-                              subsrc,
-                              srcx,
-                              srcy,
-                              srcz,
-                              width,
-                              height);
+                              src_level,
+                              src_box);
 }
 
 static void
@@ -767,34 +767,15 @@ galahad_clear_depth_stencil(struct pipe_context *_pipe,
 
 static void
 galahad_flush(struct pipe_context *_pipe,
-               unsigned flags,
                struct pipe_fence_handle **fence)
 {
    struct galahad_context *glhd_pipe = galahad_context(_pipe);
    struct pipe_context *pipe = glhd_pipe->pipe;
 
    pipe->flush(pipe,
-               flags,
                fence);
 }
 
-static unsigned int
-galahad_is_resource_referenced(struct pipe_context *_pipe,
-                                struct pipe_resource *_resource,
-                                unsigned face,
-                                unsigned level)
-{
-   struct galahad_context *glhd_pipe = galahad_context(_pipe);
-   struct galahad_resource *glhd_resource = galahad_resource(_resource);
-   struct pipe_context *pipe = glhd_pipe->pipe;
-   struct pipe_resource *resource = glhd_resource->resource;
-
-   return pipe->is_resource_referenced(pipe,
-                                       resource,
-                                       face,
-                                       level);
-}
-
 static struct pipe_sampler_view *
 galahad_context_create_sampler_view(struct pipe_context *_pipe,
                                      struct pipe_resource *_resource,
@@ -823,10 +804,40 @@ galahad_context_sampler_view_destroy(struct pipe_context *_pipe,
                                  galahad_sampler_view(_view));
 }
 
+static struct pipe_surface *
+galahad_context_create_surface(struct pipe_context *_pipe,
+                                struct pipe_resource *_resource,
+                                const struct pipe_surface *templ)
+{
+   struct galahad_context *glhd_context = galahad_context(_pipe);
+   struct galahad_resource *glhd_resource = galahad_resource(_resource);
+   struct pipe_context *pipe = glhd_context->pipe;
+   struct pipe_resource *resource = glhd_resource->resource;
+   struct pipe_surface *result;
+
+   result = pipe->create_surface(pipe,
+                                 resource,
+                                 templ);
+
+   if (result)
+      return galahad_surface_create(glhd_context, glhd_resource, result);
+   return NULL;
+}
+
+static void
+galahad_context_surface_destroy(struct pipe_context *_pipe,
+                                struct pipe_surface *_surface)
+{
+   galahad_surface_destroy(galahad_context(_pipe),
+                           galahad_surface(_surface));
+}
+
+
+
 static struct pipe_transfer *
 galahad_context_get_transfer(struct pipe_context *_context,
                               struct pipe_resource *_resource,
-                              struct pipe_subresource sr,
+                              unsigned level,
                               unsigned usage,
                               const struct pipe_box *box)
 {
@@ -838,7 +849,7 @@ galahad_context_get_transfer(struct pipe_context *_context,
 
    result = context->get_transfer(context,
                                   resource,
-                                  sr,
+                                  level,
                                   usage,
                                   box);
 
@@ -915,7 +926,7 @@ galahad_context_transfer_unmap(struct pipe_context *_context,
 static void
 galahad_context_transfer_inline_write(struct pipe_context *_context,
                                        struct pipe_resource *_resource,
-                                       struct pipe_subresource sr,
+                                       unsigned level,
                                        unsigned usage,
                                        const struct pipe_box *box,
                                        const void *data,
@@ -929,7 +940,7 @@ galahad_context_transfer_inline_write(struct pipe_context *_context,
 
    context->transfer_inline_write(context,
                                   resource,
-                                  sr,
+                                  level,
                                   usage,
                                   box,
                                   data,
@@ -938,6 +949,19 @@ galahad_context_transfer_inline_write(struct pipe_context *_context,
 }
 
 
+static void galahad_redefine_user_buffer(struct pipe_context *_context,
+                                         struct pipe_resource *_resource,
+                                         unsigned offset, unsigned size)
+{
+   struct galahad_context *glhd_context = galahad_context(_context);
+   struct galahad_resource *glhd_resource = galahad_resource(_resource);
+   struct pipe_context *context = glhd_context->pipe;
+   struct pipe_resource *resource = glhd_resource->resource;
+
+   context->redefine_user_buffer(context, resource, offset, size);
+}
+
+
 struct pipe_context *
 galahad_context_create(struct pipe_screen *_screen, struct pipe_context *pipe)
 {
@@ -1001,19 +1025,21 @@ galahad_context_create(struct pipe_screen *_screen, struct pipe_context *pipe)
    glhd_pipe->base.clear_render_target = galahad_clear_render_target;
    glhd_pipe->base.clear_depth_stencil = galahad_clear_depth_stencil;
    glhd_pipe->base.flush = galahad_flush;
-   glhd_pipe->base.is_resource_referenced = galahad_is_resource_referenced;
    glhd_pipe->base.create_sampler_view = galahad_context_create_sampler_view;
    glhd_pipe->base.sampler_view_destroy = galahad_context_sampler_view_destroy;
+   glhd_pipe->base.create_surface = galahad_context_create_surface;
+   glhd_pipe->base.surface_destroy = galahad_context_surface_destroy;
    glhd_pipe->base.get_transfer = galahad_context_get_transfer;
    glhd_pipe->base.transfer_destroy = galahad_context_transfer_destroy;
    glhd_pipe->base.transfer_map = galahad_context_transfer_map;
    glhd_pipe->base.transfer_unmap = galahad_context_transfer_unmap;
    glhd_pipe->base.transfer_flush_region = galahad_context_transfer_flush_region;
    glhd_pipe->base.transfer_inline_write = galahad_context_transfer_inline_write;
+   glhd_pipe->base.redefine_user_buffer = galahad_redefine_user_buffer;
 
    glhd_pipe->pipe = pipe;
 
-   glhd_warn("Created context %p", glhd_pipe);
+   glhd_warn("Created context %p", (void *) glhd_pipe);
 
    return &glhd_pipe->base;
 }