#include "pipe/p_screen.h"
#include "util/u_memory.h"
#include "util/u_bitmask.h"
-#include "util/u_upload_mgr.h"
#include "svga_context.h"
#include "svga_screen.h"
static void svga_destroy( struct pipe_context *pipe )
{
struct svga_context *svga = svga_context( pipe );
+ struct svga_winsys_screen *sws = svga_screen(pipe->screen)->sws;
unsigned shader;
+ util_blitter_destroy(svga->blitter);
+
svga_cleanup_framebuffer( svga );
svga_cleanup_tss_binding( svga );
svga_destroy_swtnl( svga );
- u_upload_destroy( svga->upload_vb );
- u_upload_destroy( svga->upload_ib );
-
- util_bitmask_destroy( svga->vs_bm );
- util_bitmask_destroy( svga->fs_bm );
+ util_bitmask_destroy( svga->shader_id_bm );
- for(shader = 0; shader < PIPE_SHADER_TYPES; ++shader)
- pipe_resource_reference( &svga->curr.cb[shader], NULL );
+ for (shader = 0; shader < PIPE_SHADER_TYPES; ++shader) {
+ pipe_resource_reference( &svga->curr.cbufs[shader].buffer, NULL );
+ sws->surface_reference(sws, &svga->state.hw_draw.hw_cb[shader], NULL);
+ }
FREE( svga );
}
-struct pipe_context *svga_context_create( struct pipe_screen *screen,
- void *priv )
+struct pipe_context *svga_context_create(struct pipe_screen *screen,
+ void *priv, unsigned flags)
{
struct svga_screen *svgascreen = svga_screen(screen);
struct svga_context *svga = NULL;
if (svga == NULL)
goto no_svga;
- svga->pipe.winsys = screen->winsys;
+ LIST_INITHEAD(&svga->dirty_buffers);
+
svga->pipe.screen = screen;
svga->pipe.priv = priv;
svga->pipe.destroy = svga_destroy;
svga->debug.no_line_width = debug_get_option_no_line_width();
svga->debug.force_hw_line_stipple = debug_get_option_force_hw_line_stipple();
- svga->fs_bm = util_bitmask_create();
- if (svga->fs_bm == NULL)
- goto no_fs_bm;
-
- svga->vs_bm = util_bitmask_create();
- if (svga->vs_bm == NULL)
- goto no_vs_bm;
-
- svga->upload_ib = u_upload_create( &svga->pipe,
- 32 * 1024,
- 16,
- PIPE_BIND_INDEX_BUFFER );
- if (svga->upload_ib == NULL)
- goto no_upload_ib;
-
- svga->upload_vb = u_upload_create( &svga->pipe,
- 128 * 1024,
- 16,
- PIPE_BIND_VERTEX_BUFFER );
- if (svga->upload_vb == NULL)
- goto no_upload_vb;
-
- svga->hwtnl = svga_hwtnl_create( svga,
- svga->upload_ib,
- svga->swc );
+ svga->shader_id_bm = util_bitmask_create();
+ if (svga->shader_id_bm == NULL)
+ goto no_shader_bm;
+
+ svga->hwtnl = svga_hwtnl_create(svga);
if (svga->hwtnl == NULL)
goto no_hwtnl;
memset(&svga->state.hw_draw, 0xcd, sizeof(svga->state.hw_draw));
memset(&svga->state.hw_draw.views, 0x0, sizeof(svga->state.hw_draw.views));
svga->state.hw_draw.num_views = 0;
+ memset(&svga->state.hw_draw.hw_cb, 0x0, sizeof(svga->state.hw_draw.hw_cb));
svga->dirty = ~0;
- LIST_INITHEAD(&svga->dirty_buffers);
-
return &svga->pipe;
no_state:
no_swtnl:
svga_hwtnl_destroy( svga->hwtnl );
no_hwtnl:
- u_upload_destroy( svga->upload_vb );
-no_upload_vb:
- u_upload_destroy( svga->upload_ib );
-no_upload_ib:
- util_bitmask_destroy( svga->vs_bm );
-no_vs_bm:
- util_bitmask_destroy( svga->fs_bm );
-no_fs_bm:
+ util_bitmask_destroy( svga->shader_id_bm );
+no_shader_bm:
svga->swc->destroy(svga->swc);
no_swc:
FREE(svga);
svga->curr.nr_fbs = 0;
- /* Flush the upload managers to ensure recycling of upload buffers
- * without throttling. This should really be conditioned on
- * pipe_buffer_map_range not supporting PIPE_TRANSFER_UNSYNCHRONIZED.
- */
-
- u_upload_flush(svga->upload_vb);
- u_upload_flush(svga->upload_ib);
-
/* Ensure that texture dma uploads are processed
* before submitting commands.
*/
*/
svga->rebind.rendertargets = TRUE;
svga->rebind.texture_samplers = TRUE;
+ if (svga_have_gb_objects(svga)) {
+ svga->rebind.vs = TRUE;
+ svga->rebind.fs = TRUE;
+ }
if (SVGA_DEBUG & DEBUG_SYNC) {
if (fence)
}
+/**
+ * Flush the primitive queue if this buffer is referred.
+ *
+ * Otherwise DMA commands on the referred buffer will be emitted too late.
+ */
+void svga_hwtnl_flush_buffer( struct svga_context *svga,
+ struct pipe_resource *buffer )
+{
+ if (svga_hwtnl_is_buffer_referred(svga->hwtnl, buffer)) {
+ svga_hwtnl_flush_retry(svga);
+ }
+}
+
+
/* Emit all operations pending on host surfaces.
*/
void svga_surfaces_flush(struct svga_context *svga)
{
+ struct svga_screen *svgascreen = svga_screen(svga->pipe.screen);
unsigned i;
/* Emit buffered drawing commands.
/* Emit back-copy from render target view to texture.
*/
- for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {
+ for (i = 0; i < svgascreen->max_color_buffers; i++) {
if (svga->curr.framebuffer.cbufs[i])
svga_propagate_surface(svga, svga->curr.framebuffer.cbufs[i]);
}