#define DBG 0
-
-
static enum pipe_error generate_indices( struct svga_hwtnl *hwtnl,
unsigned nr,
unsigned index_size,
struct pipe_resource *dst = NULL;
void *dst_map = NULL;
- dst = pipe_buffer_create( pipe->screen,
- PIPE_BIND_INDEX_BUFFER,
+ dst = pipe_buffer_create( pipe->screen,
+ PIPE_BIND_INDEX_BUFFER,
PIPE_USAGE_STATIC,
size );
if (dst == NULL)
if (dst)
pipe->screen->resource_destroy( pipe->screen, dst );
-
+
return PIPE_ERROR_OUT_OF_MEMORY;
}
+
static boolean compare( unsigned cached_nr,
unsigned nr,
unsigned type )
return cached_nr == nr;
}
+
static enum pipe_error retrieve_or_generate_indices( struct svga_hwtnl *hwtnl,
unsigned prim,
unsigned gen_type,
pipe_resource_reference( out_buf,
hwtnl->index_cache[prim][i].buffer );
- if (DBG)
+ if (DBG)
debug_printf("%s retrieve %d/%d\n", __FUNCTION__, i, gen_nr);
return PIPE_OK;
}
- else if (gen_type == U_GENERATE_REUSABLE)
+ else if (gen_type == U_GENERATE_REUSABLE)
{
pipe_resource_reference( &hwtnl->index_cache[prim][i].buffer,
NULL );
- if (DBG)
- debug_printf("%s discard %d/%d\n", __FUNCTION__,
+ if (DBG)
+ debug_printf("%s discard %d/%d\n", __FUNCTION__,
i, hwtnl->index_cache[prim][i].gen_nr);
break;
{
unsigned smallest = 0;
unsigned smallest_size = ~0;
-
+
for (i = 0; i < IDX_CACHE_MAX && smallest_size; i++) {
if (hwtnl->index_cache[prim][i].buffer == NULL)
{
NULL );
if (DBG)
- debug_printf("%s discard smallest %d/%d\n", __FUNCTION__,
+ debug_printf("%s discard smallest %d/%d\n", __FUNCTION__,
smallest, smallest_size);
-
+
i = smallest;
}
-
-
- ret = generate_indices( hwtnl,
+
+ ret = generate_indices( hwtnl,
gen_nr,
gen_size,
generate,
*out_buf );
if (DBG)
- debug_printf("%s cache %d/%d\n", __FUNCTION__,
+ debug_printf("%s cache %d/%d\n", __FUNCTION__,
i, hwtnl->index_cache[prim][i].gen_nr);
return PIPE_OK;
hw_prim = svga_translate_prim(prim, count, &hw_count);
if (hw_count == 0)
return PIPE_ERROR_BAD_INPUT;
-
+
range.primType = hw_prim;
range.primitiveCount = hw_count;
range.indexArray.surfaceId = SVGA3D_INVALID_ID;
}
-
-
-
-
-
-
-
-
-enum pipe_error
+enum pipe_error
svga_hwtnl_draw_arrays( struct svga_hwtnl *hwtnl,
- unsigned prim,
- unsigned start,
+ unsigned prim,
+ unsigned start,
unsigned count)
{
unsigned gen_prim, gen_size, gen_nr, gen_type;
u_generate_func gen_func;
enum pipe_error ret = PIPE_OK;
- if (hwtnl->api_fillmode != PIPE_POLYGON_MODE_FILL &&
- prim >= PIPE_PRIM_TRIANGLES)
+ if (hwtnl->api_fillmode != PIPE_POLYGON_MODE_FILL &&
+ prim >= PIPE_PRIM_TRIANGLES)
{
gen_type = u_unfilled_generator( prim,
start,
else {
struct pipe_resource *gen_buf = NULL;
- /* Need to draw as indexed primitive.
+ /* Need to draw as indexed primitive.
* Potentially need to run the gen func to build an index buffer.
*/
ret = retrieve_or_generate_indices( hwtnl,
return ret;
}
}
-
#include "svga_resource_buffer.h"
#include "svga_winsys.h"
#include "svga_context.h"
-
#include "svga_hw_reg.h"
struct pipe_resource *dst = NULL;
void *dst_map = NULL;
- dst = pipe_buffer_create( pipe->screen,
- PIPE_BIND_INDEX_BUFFER,
+ dst = pipe_buffer_create( pipe->screen,
+ PIPE_BIND_INDEX_BUFFER,
PIPE_USAGE_STATIC,
size );
if (dst == NULL)
int index_bias,
unsigned min_index,
unsigned max_index,
- unsigned prim,
+ unsigned prim,
unsigned start,
unsigned count )
{
if (hw_count == 0)
goto done;
- if (index_buffer &&
- svga_buffer_is_user_buffer(index_buffer))
+ if (index_buffer &&
+ svga_buffer_is_user_buffer(index_buffer))
{
assert( index_buffer->width0 >= index_offset + count * index_size );
range.indexArray.stride = index_size;
range.indexWidth = index_size;
range.indexBias = index_bias;
-
+
ret = svga_hwtnl_prim( hwtnl, &range, min_index, max_index, index_buffer );
if (ret != PIPE_OK)
goto done;
u_translate_func gen_func;
enum pipe_error ret = PIPE_OK;
- if (hwtnl->api_fillmode != PIPE_POLYGON_MODE_FILL &&
- prim >= PIPE_PRIM_TRIANGLES)
+ if (hwtnl->api_fillmode != PIPE_POLYGON_MODE_FILL &&
+ prim >= PIPE_PRIM_TRIANGLES)
{
gen_type = u_unfilled_translator( prim,
index_size,
&gen_func );
}
-
if (gen_type == U_TRANSLATE_MEMCPY) {
- /* No need for translation, just pass through to hardware:
+ /* No need for translation, just pass through to hardware:
*/
return svga_hwtnl_simple_draw_range_elements( hwtnl, index_buffer,
index_size,
return ret;
}
}
-
-
-
-
-
*
**********************************************************/
-#include "svga_cmd.h"
#include "util/u_format.h"
#include "util/u_inlines.h"
#include "util/u_prim.h"
#include "util/u_time.h"
+#include "util/u_upload_mgr.h"
#include "indices/u_indices.h"
#include "svga_hw_reg.h"
+#include "svga_cmd.h"
#include "svga_context.h"
#include "svga_screen.h"
#include "svga_draw.h"
#include "svga_swtnl.h"
#include "svga_debug.h"
#include "svga_resource_buffer.h"
-#include "util/u_upload_mgr.h"
+
/**
* Determine the ranges to upload for the user-buffers referenced
* may be uploaded to different hardware buffers chosen by the utility
* upload manager.
*/
-
static void
svga_user_buffer_range(struct svga_context *svga,
unsigned start,
}
}
+
/**
* svga_upload_user_buffers - upload parts of user buffers
*
* This function streams a part of a user buffer to hw and fills
* svga_buffer::uploaded with information on the upload.
*/
-
static int
svga_upload_user_buffers(struct svga_context *svga,
unsigned start,
return PIPE_OK;
}
+
/**
* svga_release_user_upl_buffers - release uploaded parts of user buffers
*
* svga_buffer::source_offset is set to 0, and svga_buffer::uploaded::buffer
* is set to 0.
*/
-
static void
svga_release_user_upl_buffers(struct svga_context *svga)
{
int index_bias,
unsigned min_index,
unsigned max_index,
- unsigned prim,
- unsigned start,
+ unsigned prim,
+ unsigned start,
unsigned count,
unsigned instance_count,
boolean do_retry )
static enum pipe_error
retry_draw_arrays( struct svga_context *svga,
- unsigned prim,
- unsigned start,
+ unsigned prim,
+ unsigned start,
unsigned count,
unsigned instance_count,
boolean do_retry )
return PIPE_OK;
retry:
- if (ret == PIPE_ERROR_OUT_OF_MEMORY && do_retry)
+ if (ret == PIPE_ERROR_OUT_OF_MEMORY && do_retry)
{
svga_context_flush( svga, NULL );
svga->curr.reduced_prim = reduced_prim;
svga->dirty |= SVGA_NEW_REDUCED_PRIMITIVE;
}
-
+
needed_swtnl = svga->state.sw.need_swtnl;
svga_update_state_retry( svga, SVGA_STATE_NEED_SWTNL );
#include "util/u_inlines.h"
#include "pipe/p_state.h"
-
-
#include "svga_context.h"
#include "svga_state.h"
#include "svga_debug.h"
#include "svga_hw_reg.h"
-/***********************************************************************
- */
-
/**
* Given a gallium vertex element format, return the corresponding SVGA3D
* format. Return SVGA3D_DECLTYPE_MAX for unsupported gallium formats.
*/
-static INLINE SVGA3dDeclType
+static INLINE SVGA3dDeclType
svga_translate_vertex_format(enum pipe_format format)
{
switch (format) {
static enum pipe_error
-update_need_swvfetch( struct svga_context *svga,
- unsigned dirty )
+update_need_swvfetch(struct svga_context *svga, unsigned dirty)
{
unsigned i;
boolean need_swvfetch = FALSE;
svga->state.sw.need_swvfetch = need_swvfetch;
svga->dirty |= SVGA_NEW_NEED_SWVFETCH;
}
-
+
return PIPE_OK;
}
-struct svga_tracked_state svga_update_need_swvfetch =
+struct svga_tracked_state svga_update_need_swvfetch =
{
"update need_swvfetch",
( SVGA_NEW_VELEMENT ),
};
-/***********************************************************************
- */
static enum pipe_error
-update_need_pipeline( struct svga_context *svga,
- unsigned dirty )
+update_need_pipeline(struct svga_context *svga, unsigned dirty)
{
-
boolean need_pipeline = FALSE;
struct svga_vertex_shader *vs = svga->curr.vs;
}
-struct svga_tracked_state svga_update_need_pipeline =
+struct svga_tracked_state svga_update_need_pipeline =
{
"need pipeline",
(SVGA_NEW_RAST |
};
-/***********************************************************************
- */
-
static enum pipe_error
-update_need_swtnl( struct svga_context *svga,
- unsigned dirty )
+update_need_swtnl(struct svga_context *svga, unsigned dirty)
{
boolean need_swtnl;
svga->dirty |= SVGA_NEW_NEED_SWTNL;
svga->swtnl.new_vdecl = TRUE;
}
-
+
return PIPE_OK;
}
#include "svga_tgsi.h"
#include "svga_screen.h"
#include "svga_resource_buffer.h"
-
#include "svga_hw_reg.h"
-/***********************************************************************
- */
-
static enum pipe_error
emit_hw_vs_vdecl(struct svga_context *svga, unsigned dirty)
assert(svga->curr.velems->count >=
svga->curr.vs->base.info.file_count[TGSI_FILE_INPUT]);
- svga_hwtnl_reset_vdecl( svga->hwtnl,
+ svga_hwtnl_reset_vdecl( svga->hwtnl,
svga->curr.velems->count );
/**
}
-struct svga_tracked_state svga_hw_vdecl =
+struct svga_tracked_state svga_hw_vdecl =
{
"hw vertex decl state (hwtnl version)",
( SVGA_NEW_NEED_SWTNL |
SVGA_NEW_VS ),
emit_hw_vdecl
};
-
-
-
-
-
-