r600g: fix RSQ of negative value on Cayman
[mesa.git] / src / gallium / drivers / r600 / r600_pipe.c
index cf2983315b2e1f8a26e434bd3215759bc8dc683e..0a7b0ac2012e57107544e071dc2ec87bf03afeb2 100644 (file)
@@ -156,6 +156,12 @@ static void r600_destroy_context(struct pipe_context *context)
 {
        struct r600_context *rctx = (struct r600_context *)context;
 
+       pipe_resource_reference((struct pipe_resource**)&rctx->dummy_cmask, NULL);
+       pipe_resource_reference((struct pipe_resource**)&rctx->dummy_fmask, NULL);
+
+       if (rctx->no_blend) {
+               rctx->context.delete_blend_state(&rctx->context, rctx->no_blend);
+       }
        if (rctx->dummy_pixel_shader) {
                rctx->context.delete_fs_state(&rctx->context, rctx->dummy_pixel_shader);
        }
@@ -165,7 +171,10 @@ static void r600_destroy_context(struct pipe_context *context)
        if (rctx->custom_blend_resolve) {
                rctx->context.delete_blend_state(&rctx->context, rctx->custom_blend_resolve);
        }
-       util_unreference_framebuffer_state(&rctx->framebuffer);
+       if (rctx->custom_blend_decompress) {
+               rctx->context.delete_blend_state(&rctx->context, rctx->custom_blend_decompress);
+       }
+       util_unreference_framebuffer_state(&rctx->framebuffer.state);
 
        r600_context_fini(rctx);
 
@@ -195,6 +204,7 @@ static struct pipe_context *r600_create_context(struct pipe_screen *screen, void
 {
        struct r600_context *rctx = CALLOC_STRUCT(r600_context);
        struct r600_screen* rscreen = (struct r600_screen *)screen;
+       struct pipe_blend_state no_blend = {};
 
        if (rctx == NULL)
                return NULL;
@@ -213,8 +223,8 @@ static struct pipe_context *r600_create_context(struct pipe_screen *screen, void
        rctx->ws = rscreen->ws;
        rctx->family = rscreen->family;
        rctx->chip_class = rscreen->chip_class;
+       rctx->keep_tiling_flags = rscreen->info.drm_minor >= 12;
 
-       LIST_INITHEAD(&rctx->dirty_states);
        LIST_INITHEAD(&rctx->active_timer_queries);
        LIST_INITHEAD(&rctx->active_nontimer_queries);
        LIST_INITHEAD(&rctx->dirty);
@@ -228,12 +238,12 @@ static struct pipe_context *r600_create_context(struct pipe_screen *screen, void
        r600_init_query_functions(rctx);
        r600_init_context_resource_functions(rctx);
        r600_init_surface_functions(rctx);
-       rctx->context.draw_vbo = r600_draw_vbo;
+
 
        rctx->context.create_video_decoder = vl_create_decoder;
        rctx->context.create_video_buffer = vl_video_buffer_create;
 
-       r600_init_common_atoms(rctx);
+       r600_init_common_state_functions(rctx);
 
        switch (rctx->chip_class) {
        case R600:
@@ -243,6 +253,9 @@ static struct pipe_context *r600_create_context(struct pipe_screen *screen, void
                if (r600_context_init(rctx))
                        goto fail;
                rctx->custom_dsa_flush = r600_create_db_flush_dsa(rctx);
+               rctx->custom_blend_resolve = rctx->chip_class == R700 ? r700_create_resolve_blend(rctx)
+                                                                     : r600_create_resolve_blend(rctx);
+               rctx->custom_blend_decompress = r600_create_decompress_blend(rctx);
                rctx->has_vertex_cache = !(rctx->family == CHIP_RV610 ||
                                           rctx->family == CHIP_RV620 ||
                                           rctx->family == CHIP_RS780 ||
@@ -258,6 +271,7 @@ static struct pipe_context *r600_create_context(struct pipe_screen *screen, void
                        goto fail;
                rctx->custom_dsa_flush = evergreen_create_db_flush_dsa(rctx);
                rctx->custom_blend_resolve = evergreen_create_resolve_blend(rctx);
+               rctx->custom_blend_decompress = evergreen_create_decompress_blend(rctx);
                rctx->has_vertex_cache = !(rctx->family == CHIP_CEDAR ||
                                           rctx->family == CHIP_PALM ||
                                           rctx->family == CHIP_SUMO ||
@@ -273,7 +287,6 @@ static struct pipe_context *r600_create_context(struct pipe_screen *screen, void
 
        rctx->cs = rctx->ws->cs_create(rctx->ws);
        rctx->ws->cs_set_flush_callback(rctx->cs, r600_flush_from_winsys, rctx);
-       r600_emit_atom(rctx, &rctx->start_cs_cmd.atom);
 
         rctx->uploader = u_upload_create(&rctx->context, 1024 * 1024, 256,
                                          PIPE_BIND_INDEX_BUFFER |
@@ -284,7 +297,9 @@ static struct pipe_context *r600_create_context(struct pipe_screen *screen, void
        rctx->blitter = util_blitter_create(&rctx->context);
        if (rctx->blitter == NULL)
                goto fail;
+       rctx->blitter->draw_rectangle = r600_draw_rectangle;
 
+       r600_begin_new_cs(rctx);
        r600_get_backend_mask(rctx); /* this emits commands and must be last */
 
        if (rctx->chip_class == R600)
@@ -296,6 +311,9 @@ static struct pipe_context *r600_create_context(struct pipe_screen *screen, void
                                                     TGSI_INTERPOLATE_CONSTANT);
        rctx->context.bind_fs_state(&rctx->context, rctx->dummy_pixel_shader);
 
+       no_blend.rt[0].colormask = 0xF;
+       rctx->no_blend = rctx->context.create_blend_state(&rctx->context, &no_blend);
+
        return &rctx->context;
 
 fail:
@@ -649,6 +667,22 @@ static int r600_get_compute_param(struct pipe_screen *screen,
                }
                return sizeof(uint64_t);
 
+       case PIPE_COMPUTE_CAP_MAX_MEM_ALLOC_SIZE:
+               if (ret) {
+                       uint64_t max_global_size;
+                       uint64_t * max_mem_alloc_size = ret;
+                       r600_get_compute_param(screen,
+                                       PIPE_COMPUTE_CAP_MAX_GLOBAL_SIZE,
+                                       &max_global_size);
+                       /* OpenCL requres this value be at least
+                        * max(MAX_GLOBAL_SIZE / 4, 128 * 1024 *1024)
+                        * I'm really not sure what value to report here, but
+                        * MAX_GLOBAL_SIZE / 4 seems resonable.
+                        */
+                       *max_mem_alloc_size = max_global_size / 4;
+               }
+               return sizeof(uint64_t);
+
        default:
                fprintf(stderr, "unknown PIPE_COMPUTE_CAP %d\n", param);
                return 0;
@@ -916,14 +950,12 @@ struct pipe_screen *r600_screen_create(struct radeon_winsys *ws)
        switch (rscreen->chip_class) {
        case R600:
        case EVERGREEN:
+       case CAYMAN:
                rscreen->has_streamout = rscreen->info.drm_minor >= 14;
                break;
        case R700:
                rscreen->has_streamout = rscreen->info.drm_minor >= 17;
                break;
-       /* TODO: Cayman */
-       default:
-               rscreen->has_streamout = debug_get_bool_option("R600_STREAMOUT", FALSE);
        }
 
        if (r600_init_tiling(rscreen)) {