radeonsi: use r600_draw_rectangle from r600g
authorMarek Olšák <marek.olsak@amd.com>
Sun, 17 Aug 2014 22:55:40 +0000 (00:55 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 19 Aug 2014 10:20:18 +0000 (12:20 +0200)
Rectangles are easier than triangles for the rasterizer.

Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
src/gallium/drivers/r600/r600_blit.c
src/gallium/drivers/r600/r600_pipe.c
src/gallium/drivers/r600/r600_pipe.h
src/gallium/drivers/r600/r600_state_common.c
src/gallium/drivers/radeon/r600_pipe_common.c
src/gallium/drivers/radeon/r600_pipe_common.h
src/gallium/drivers/radeonsi/si_blit.c
src/gallium/drivers/radeonsi/si_pipe.c
src/gallium/drivers/radeonsi/si_state_draw.c

index c98206fe9038532cf7570680116506326052376f..a3cfdae6b73c1cfd0bccfc56264de07125f8e388 100644 (file)
@@ -22,7 +22,6 @@
  */
 #include "r600_pipe.h"
 #include "util/u_surface.h"
-#include "util/u_blitter.h"
 #include "util/u_format.h"
 #include "evergreend.h"
 
index 4543347555e0198722a57a5665557541831aa16c..226ad6e0200eff48189d165e3de393a4ee4d7d4b 100644 (file)
@@ -30,7 +30,6 @@
 
 #include <errno.h>
 #include "pipe/p_shader_tokens.h"
-#include "util/u_blitter.h"
 #include "util/u_debug.h"
 #include "util/u_memory.h"
 #include "util/u_simple_shaders.h"
index d04fef80df1f3ddc773737937631e0e7d066d1b5..ee836b771f752065d8db55ee58ffb28e90efaefe 100644 (file)
@@ -32,7 +32,6 @@
 #include "r600_llvm.h"
 #include "r600_public.h"
 
-#include "util/u_blitter.h"
 #include "util/u_suballoc.h"
 #include "util/u_double_list.h"
 #include "util/u_transfer.h"
@@ -633,9 +632,6 @@ void r600_sampler_views_dirty(struct r600_context *rctx,
 void r600_sampler_states_dirty(struct r600_context *rctx,
                               struct r600_sampler_states *state);
 void r600_constant_buffers_dirty(struct r600_context *rctx, struct r600_constbuf_state *state);
-void r600_draw_rectangle(struct blitter_context *blitter,
-                        int x1, int y1, int x2, int y2, float depth,
-                        enum blitter_attrib_type type, const union pipe_color_union *attrib);
 uint32_t r600_translate_stencil_op(int s_op);
 uint32_t r600_translate_fill(uint32_t func);
 unsigned r600_tex_wrap(unsigned wrap);
index d29e137d511a6b08fce1e668cdd8726b49700736..d2f0d174c9f3adab2b5d5add024a0bd71444738c 100644 (file)
@@ -28,7 +28,6 @@
 #include "r600_shader.h"
 #include "r600d.h"
 
-#include "util/u_draw_quad.h"
 #include "util/u_format_s3tc.h"
 #include "util/u_index_modify.h"
 #include "util/u_memory.h"
@@ -36,8 +35,6 @@
 #include "util/u_math.h"
 #include "tgsi/tgsi_parse.h"
 
-#define R600_PRIM_RECTANGLE_LIST PIPE_PRIM_MAX
-
 void r600_init_command_buffer(struct r600_command_buffer *cb, unsigned num_dw)
 {
        assert(!cb->buf);
@@ -1550,67 +1547,6 @@ static void r600_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info
        rctx->b.num_draw_calls++;
 }
 
-void r600_draw_rectangle(struct blitter_context *blitter,
-                        int x1, int y1, int x2, int y2, float depth,
-                        enum blitter_attrib_type type, const union pipe_color_union *attrib)
-{
-       struct r600_context *rctx = (struct r600_context*)util_blitter_get_pipe(blitter);
-       struct pipe_viewport_state viewport;
-       struct pipe_resource *buf = NULL;
-       unsigned offset = 0;
-       float *vb;
-
-       if (type == UTIL_BLITTER_ATTRIB_TEXCOORD) {
-               util_blitter_draw_rectangle(blitter, x1, y1, x2, y2, depth, type, attrib);
-               return;
-       }
-
-       /* Some operations (like color resolve on r6xx) don't work
-        * with the conventional primitive types.
-        * One that works is PT_RECTLIST, which we use here. */
-
-       /* setup viewport */
-       viewport.scale[0] = 1.0f;
-       viewport.scale[1] = 1.0f;
-       viewport.scale[2] = 1.0f;
-       viewport.scale[3] = 1.0f;
-       viewport.translate[0] = 0.0f;
-       viewport.translate[1] = 0.0f;
-       viewport.translate[2] = 0.0f;
-       viewport.translate[3] = 0.0f;
-       rctx->b.b.set_viewport_states(&rctx->b.b, 0, 1, &viewport);
-
-       /* Upload vertices. The hw rectangle has only 3 vertices,
-        * I guess the 4th one is derived from the first 3.
-        * The vertex specification should match u_blitter's vertex element state. */
-       u_upload_alloc(rctx->b.uploader, 0, sizeof(float) * 24, &offset, &buf, (void**)&vb);
-       vb[0] = x1;
-       vb[1] = y1;
-       vb[2] = depth;
-       vb[3] = 1;
-
-       vb[8] = x1;
-       vb[9] = y2;
-       vb[10] = depth;
-       vb[11] = 1;
-
-       vb[16] = x2;
-       vb[17] = y1;
-       vb[18] = depth;
-       vb[19] = 1;
-
-       if (attrib) {
-               memcpy(vb+4, attrib->f, sizeof(float)*4);
-               memcpy(vb+12, attrib->f, sizeof(float)*4);
-               memcpy(vb+20, attrib->f, sizeof(float)*4);
-       }
-
-       /* draw */
-       util_draw_vertex_buffer(&rctx->b.b, NULL, buf, rctx->blitter->vb_slot, offset,
-                               R600_PRIM_RECTANGLE_LIST, 3, 2);
-       pipe_resource_reference(&buf, NULL);
-}
-
 uint32_t r600_translate_stencil_op(int s_op)
 {
        switch (s_op) {
index 5ceadb4d3e5d94ddb0161deb45c821ba334efa9b..a6bba8f0a94d47c8a72043aea28aa6759f697fda 100644 (file)
@@ -27,6 +27,7 @@
 #include "r600_pipe_common.h"
 #include "r600_cs.h"
 #include "tgsi/tgsi_parse.h"
+#include "util/u_draw_quad.h"
 #include "util/u_memory.h"
 #include "util/u_format_s3tc.h"
 #include "util/u_upload_mgr.h"
  * pipe_context
  */
 
+void r600_draw_rectangle(struct blitter_context *blitter,
+                        int x1, int y1, int x2, int y2, float depth,
+                        enum blitter_attrib_type type,
+                        const union pipe_color_union *attrib)
+{
+       struct r600_common_context *rctx =
+               (struct r600_common_context*)util_blitter_get_pipe(blitter);
+       struct pipe_viewport_state viewport;
+       struct pipe_resource *buf = NULL;
+       unsigned offset = 0;
+       float *vb;
+
+       if (type == UTIL_BLITTER_ATTRIB_TEXCOORD) {
+               util_blitter_draw_rectangle(blitter, x1, y1, x2, y2, depth, type, attrib);
+               return;
+       }
+
+       /* Some operations (like color resolve on r6xx) don't work
+        * with the conventional primitive types.
+        * One that works is PT_RECTLIST, which we use here. */
+
+       /* setup viewport */
+       viewport.scale[0] = 1.0f;
+       viewport.scale[1] = 1.0f;
+       viewport.scale[2] = 1.0f;
+       viewport.scale[3] = 1.0f;
+       viewport.translate[0] = 0.0f;
+       viewport.translate[1] = 0.0f;
+       viewport.translate[2] = 0.0f;
+       viewport.translate[3] = 0.0f;
+       rctx->b.set_viewport_states(&rctx->b, 0, 1, &viewport);
+
+       /* Upload vertices. The hw rectangle has only 3 vertices,
+        * I guess the 4th one is derived from the first 3.
+        * The vertex specification should match u_blitter's vertex element state. */
+       u_upload_alloc(rctx->uploader, 0, sizeof(float) * 24, &offset, &buf, (void**)&vb);
+       vb[0] = x1;
+       vb[1] = y1;
+       vb[2] = depth;
+       vb[3] = 1;
+
+       vb[8] = x1;
+       vb[9] = y2;
+       vb[10] = depth;
+       vb[11] = 1;
+
+       vb[16] = x2;
+       vb[17] = y1;
+       vb[18] = depth;
+       vb[19] = 1;
+
+       if (attrib) {
+               memcpy(vb+4, attrib->f, sizeof(float)*4);
+               memcpy(vb+12, attrib->f, sizeof(float)*4);
+               memcpy(vb+20, attrib->f, sizeof(float)*4);
+       }
+
+       /* draw */
+       util_draw_vertex_buffer(&rctx->b, NULL, buf, blitter->vb_slot, offset,
+                               R600_PRIM_RECTANGLE_LIST, 3, 2);
+       pipe_resource_reference(&buf, NULL);
+}
+
 void r600_need_dma_space(struct r600_common_context *ctx, unsigned num_dw)
 {
        /* The number of dwords we already used in the DMA so far. */
index ab348ae02ccc83f1a51720668ae7055bac9515cf..ed16e1a7b0c8c3febe5bf64c56eaa6033518af7b 100644 (file)
@@ -36,6 +36,7 @@
 
 #include "../../winsys/radeon/drm/radeon_winsys.h"
 
+#include "util/u_blitter.h"
 #include "util/u_double_list.h"
 #include "util/u_range.h"
 #include "util/u_slab.h"
@@ -74,6 +75,9 @@
 #define R600_CONTEXT_VGT_FLUSH                 (1 << 19)
 #define R600_CONTEXT_VGT_STREAMOUT_SYNC                (1 << 20)
 
+/* special primitive types */
+#define R600_PRIM_RECTANGLE_LIST       PIPE_PRIM_MAX
+
 /* Debug flags. */
 /* logging */
 #define DBG_TEX                        (1 << 0)
@@ -427,6 +431,10 @@ struct pipe_resource *r600_buffer_create(struct pipe_screen *screen,
                                         unsigned alignment);
 
 /* r600_common_pipe.c */
+void r600_draw_rectangle(struct blitter_context *blitter,
+                        int x1, int y1, int x2, int y2, float depth,
+                        enum blitter_attrib_type type,
+                        const union pipe_color_union *attrib);
 bool r600_common_screen_init(struct r600_common_screen *rscreen,
                             struct radeon_winsys *ws);
 void r600_destroy_common_screen(struct r600_common_screen *rscreen);
index 9a7a2fef690accbdc4a2dbd116a2814d7c965487..2806b468ee5a4fd78e8785c49a3b077c8abe7a2d 100644 (file)
@@ -22,7 +22,6 @@
  */
 
 #include "si_pipe.h"
-#include "util/u_blitter.h"
 #include "util/u_format.h"
 
 enum si_blitter_op /* bitmask */
index 3c3d642b791194ad3f9f83ddb986a62f9c6e8538..845ab20da373bf7b8f9fbc8769fcac72654e3272 100644 (file)
@@ -26,7 +26,6 @@
 #include "sid.h"
 
 #include "radeon/radeon_uvd.h"
-#include "util/u_blitter.h"
 #include "util/u_memory.h"
 #include "util/u_simple_shaders.h"
 #include "vl/vl_decoder.h"
@@ -128,6 +127,7 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen, void *
        sctx->blitter = util_blitter_create(&sctx->b.b);
        if (sctx->blitter == NULL)
                goto fail;
+       sctx->blitter->draw_rectangle = r600_draw_rectangle;
 
        sctx->dummy_pixel_shader =
                util_make_fragment_cloneinput_shader(&sctx->b.b, 0,
index 411ea04059fca13e000d6d676fa0a2906c361810..573487cedab216569463b5d0d673302ec57ef914 100644 (file)
@@ -29,7 +29,6 @@
 #include "../radeon/r600_cs.h"
 #include "sid.h"
 
-#include "util/u_blitter.h"
 #include "util/u_format.h"
 #include "util/u_index_modify.h"
 #include "util/u_memory.h"
@@ -346,7 +345,8 @@ static unsigned si_conv_pipe_prim(unsigned pprim)
                [PIPE_PRIM_LINES_ADJACENCY]             = V_008958_DI_PT_LINELIST_ADJ,
                [PIPE_PRIM_LINE_STRIP_ADJACENCY]        = V_008958_DI_PT_LINESTRIP_ADJ,
                [PIPE_PRIM_TRIANGLES_ADJACENCY]         = V_008958_DI_PT_TRILIST_ADJ,
-               [PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY]    = V_008958_DI_PT_TRISTRIP_ADJ
+               [PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY]    = V_008958_DI_PT_TRISTRIP_ADJ,
+               [R600_PRIM_RECTANGLE_LIST]              = V_008958_DI_PT_RECTLIST
         };
        unsigned result = prim_conv[pprim];
         if (result == ~0) {
@@ -371,7 +371,8 @@ static unsigned si_conv_prim_to_gs_out(unsigned mode)
                [PIPE_PRIM_LINES_ADJACENCY]             = V_028A6C_OUTPRIM_TYPE_LINESTRIP,
                [PIPE_PRIM_LINE_STRIP_ADJACENCY]        = V_028A6C_OUTPRIM_TYPE_LINESTRIP,
                [PIPE_PRIM_TRIANGLES_ADJACENCY]         = V_028A6C_OUTPRIM_TYPE_TRISTRIP,
-               [PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY]    = V_028A6C_OUTPRIM_TYPE_TRISTRIP
+               [PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY]    = V_028A6C_OUTPRIM_TYPE_TRISTRIP,
+               [R600_PRIM_RECTANGLE_LIST]              = V_028A6C_OUTPRIM_TYPE_TRISTRIP
        };
        assert(mode < Elements(prim_conv));