/**************************************************************************
*
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2007 VMware, Inc.
* All Rights Reserved.
* Copyright 2008 VMware, Inc. All rights reserved.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
**************************************************************************/
/* Author:
- * Keith Whitwell <keith@tungstengraphics.com>
+ * Keith Whitwell <keithw@vmware.com>
*/
#include "draw/draw_context.h"
#include "util/u_inlines.h"
#include "util/u_math.h"
#include "util/u_memory.h"
-#include "util/u_simple_list.h"
+#include "util/simple_list.h"
+#include "util/u_upload_mgr.h"
#include "lp_clear.h"
#include "lp_context.h"
#include "lp_flush.h"
#include "lp_query.h"
#include "lp_setup.h"
-
-/** shared by all contexts */
-unsigned llvmpipe_variant_count;
-
+/* This is only safe if there's just one concurrent context */
+#ifdef PIPE_SUBSYSTEM_EMBEDDED
+#define USE_GLOBAL_LLVM_CONTEXT
+#endif
static void llvmpipe_destroy( struct pipe_context *pipe )
{
util_blitter_destroy(llvmpipe->blitter);
}
+ if (llvmpipe->pipe.stream_uploader)
+ u_upload_destroy(llvmpipe->pipe.stream_uploader);
+
/* This will also destroy llvmpipe->setup:
*/
if (llvmpipe->draw)
pipe_surface_reference(&llvmpipe->framebuffer.zsbuf, NULL);
- for (i = 0; i < Elements(llvmpipe->sampler_views[0]); i++) {
+ for (i = 0; i < ARRAY_SIZE(llvmpipe->sampler_views[0]); i++) {
pipe_sampler_view_reference(&llvmpipe->sampler_views[PIPE_SHADER_FRAGMENT][i], NULL);
}
- for (i = 0; i < Elements(llvmpipe->sampler_views[0]); i++) {
+ for (i = 0; i < ARRAY_SIZE(llvmpipe->sampler_views[0]); i++) {
pipe_sampler_view_reference(&llvmpipe->sampler_views[PIPE_SHADER_VERTEX][i], NULL);
}
- for (i = 0; i < Elements(llvmpipe->constants); i++) {
- for (j = 0; j < Elements(llvmpipe->constants[i]); j++) {
- pipe_resource_reference(&llvmpipe->constants[i][j], NULL);
+ for (i = 0; i < ARRAY_SIZE(llvmpipe->sampler_views[0]); i++) {
+ pipe_sampler_view_reference(&llvmpipe->sampler_views[PIPE_SHADER_GEOMETRY][i], NULL);
+ }
+
+ for (i = 0; i < ARRAY_SIZE(llvmpipe->constants); i++) {
+ for (j = 0; j < ARRAY_SIZE(llvmpipe->constants[i]); j++) {
+ pipe_resource_reference(&llvmpipe->constants[i][j].buffer, NULL);
}
}
for (i = 0; i < llvmpipe->num_vertex_buffers; i++) {
- pipe_resource_reference(&llvmpipe->vertex_buffer[i].buffer, NULL);
+ pipe_vertex_buffer_unreference(&llvmpipe->vertex_buffer[i]);
}
lp_delete_setup_variants(llvmpipe);
+#ifndef USE_GLOBAL_LLVM_CONTEXT
+ LLVMContextDispose(llvmpipe->context);
+#endif
+ llvmpipe->context = NULL;
+
align_free( llvmpipe );
}
static void
do_flush( struct pipe_context *pipe,
- struct pipe_fence_handle **fence)
+ struct pipe_fence_handle **fence,
+ unsigned flags)
{
llvmpipe_flush(pipe, fence, __FUNCTION__);
}
static void
-llvmpipe_render_condition ( struct pipe_context *pipe,
- struct pipe_query *query,
- uint mode )
+llvmpipe_render_condition(struct pipe_context *pipe,
+ struct pipe_query *query,
+ boolean condition,
+ enum pipe_render_cond_flag mode)
{
struct llvmpipe_context *llvmpipe = llvmpipe_context( pipe );
llvmpipe->render_cond_query = query;
llvmpipe->render_cond_mode = mode;
+ llvmpipe->render_cond_cond = condition;
}
struct pipe_context *
-llvmpipe_create_context( struct pipe_screen *screen, void *priv )
+llvmpipe_create_context(struct pipe_screen *screen, void *priv,
+ unsigned flags)
{
struct llvmpipe_context *llvmpipe;
llvmpipe_init_context_resource_funcs( &llvmpipe->pipe );
llvmpipe_init_surface_functions(llvmpipe);
+#ifdef USE_GLOBAL_LLVM_CONTEXT
+ llvmpipe->context = LLVMGetGlobalContext();
+#else
+ llvmpipe->context = LLVMContextCreate();
+#endif
+
+ if (!llvmpipe->context)
+ goto fail;
+
/*
* Create drawing context and plug our rendering stage into it.
*/
- llvmpipe->draw = draw_create(&llvmpipe->pipe);
+ llvmpipe->draw = draw_create_with_llvm_context(&llvmpipe->pipe,
+ llvmpipe->context);
if (!llvmpipe->draw)
goto fail;
if (!llvmpipe->setup)
goto fail;
+ llvmpipe->pipe.stream_uploader = u_upload_create_default(&llvmpipe->pipe);
+ if (!llvmpipe->pipe.stream_uploader)
+ goto fail;
+ llvmpipe->pipe.const_uploader = llvmpipe->pipe.stream_uploader;
+
llvmpipe->blitter = util_blitter_create(&llvmpipe->pipe);
if (!llvmpipe->blitter) {
goto fail;
lp_reset_counters();
+ /* If llvmpipe_set_scissor_states() is never called, we still need to
+ * make sure that derived scissor state is computed.
+ * See https://bugs.freedesktop.org/show_bug.cgi?id=101709
+ */
+ llvmpipe->dirty |= LP_NEW_SCISSOR;
+
return &llvmpipe->pipe;
fail: