goto no_swtnl;
ret = svga_emit_initial_state( svga );
- if (ret)
+ if (ret != PIPE_OK)
goto no_state;
/* Avoid shortcircuiting state with initial value of zero.
unsigned max_index,
struct pipe_resource *ib )
{
- int ret = PIPE_OK;
+ enum pipe_error ret = PIPE_OK;
#ifdef DEBUG
{
gen_size,
gen_func,
&gen_buf );
- if (ret)
+ if (ret != PIPE_OK)
goto done;
ret = svga_hwtnl_simple_draw_range_elements( hwtnl,
0,
gen_nr );
- if (ret)
+ if (ret != PIPE_OK)
goto done;
done:
unsigned hw_prim;
unsigned hw_count;
unsigned index_offset = start * index_size;
- int ret = PIPE_OK;
+ enum pipe_error ret = PIPE_OK;
hw_prim = svga_translate_prim(prim, count, &hw_count);
if (hw_count == 0)
&index_offset,
&upload_buffer,
&flushed );
- if (ret)
+ if (ret != PIPE_OK)
goto done;
/* Don't need to worry about refcounting index_buffer as this is
range.indexBias = index_bias;
ret = svga_hwtnl_prim( hwtnl, &range, min_index, max_index, index_buffer );
- if (ret)
+ if (ret != PIPE_OK)
goto done;
done:
gen_size,
gen_func,
&gen_buf );
- if (ret)
+ if (ret != PIPE_OK)
goto done;
ret = svga_hwtnl_simple_draw_range_elements( hwtnl,
gen_prim,
0,
gen_nr );
- if (ret)
+ if (ret != PIPE_OK)
goto done;
done:
double depth,
unsigned stencil)
{
- int ret = PIPE_OK;
+ enum pipe_error ret = PIPE_OK;
SVGA3dRect rect = { 0, 0, 0, 0 };
boolean restore_viewport = FALSE;
SVGA3dClearFlag flags = 0;
union util_color uc = {0};
ret = svga_update_state(svga, SVGA_STATE_HW_CLEAR);
- if (ret)
+ if (ret != PIPE_OK)
return ret;
if (svga->rebind.rendertargets) {
if (memcmp(&rect, &svga->state.hw_clear.viewport, sizeof(rect)) != 0) {
restore_viewport = TRUE;
ret = SVGA3D_SetViewport(svga->swc, &rect);
- if (ret)
+ if (ret != PIPE_OK)
return ret;
}
double depth, unsigned stencil)
{
struct svga_context *svga = svga_context( pipe );
- int ret;
+ enum pipe_error ret;
if (buffers & PIPE_CLEAR_COLOR)
SVGA_DBG(DEBUG_DMA, "clear sid %p\n",
unsigned instance_count,
boolean do_retry )
{
- enum pipe_error ret = 0;
+ enum pipe_error ret = PIPE_OK;
svga_hwtnl_set_unfilled( svga->hwtnl,
svga->curr.rast->hw_unfilled );
goto retry;
ret = svga_update_state( svga, SVGA_STATE_HW_DRAW );
- if (ret)
+ if (ret != PIPE_OK)
goto retry;
ret = svga_hwtnl_draw_range_elements( svga->hwtnl,
index_buffer, index_size, index_bias,
min_index, max_index,
prim, start, count );
- if (ret)
+ if (ret != PIPE_OK)
goto retry;
return PIPE_OK;
goto retry;
ret = svga_update_state( svga, SVGA_STATE_HW_DRAW );
- if (ret)
+ if (ret != PIPE_OK)
goto retry;
ret = svga_hwtnl_draw_arrays( svga->hwtnl, prim,
start, count );
- if (ret)
+ if (ret != PIPE_OK)
goto retry;
return 0;
-static int update_state( struct svga_context *svga,
- const struct svga_tracked_state *atoms[],
- unsigned *state )
+static enum pipe_error
+update_state(struct svga_context *svga,
+ const struct svga_tracked_state *atoms[],
+ unsigned *state)
{
boolean debug = TRUE;
- enum pipe_error ret = 0;
+ enum pipe_error ret = PIPE_OK;
unsigned i;
ret = svga_hwtnl_flush( svga->hwtnl );
- if (ret != 0)
+ if (ret != PIPE_OK)
return ret;
if (debug) {
if (0)
debug_printf("update: %s\n", atoms[i]->name);
ret = atoms[i]->update( svga, *state );
- if (ret != 0)
+ if (ret != PIPE_OK)
return ret;
}
for (i = 0; atoms[i] != NULL; i++) {
if (check_state(*state, atoms[i]->dirty)) {
ret = atoms[i]->update( svga, *state );
- if (ret != 0)
+ if (ret != PIPE_OK)
return ret;
}
}
}
- return 0;
+ return PIPE_OK;
}
-int svga_update_state( struct svga_context *svga,
- unsigned max_level )
+enum pipe_error
+svga_update_state(struct svga_context *svga, unsigned max_level)
{
struct svga_screen *screen = svga_screen(svga->pipe.screen);
- int ret = 0;
+ enum pipe_error ret = PIPE_OK;
int i;
/* Check for updates to bound textures. This can't be done in an
ret = update_state( svga,
state_levels[i],
&svga->dirty );
- if (ret != 0)
+ if (ret != PIPE_OK)
return ret;
svga->state.dirty[i] = 0;
svga->state.dirty[i] |= svga->dirty;
svga->dirty = 0;
- return 0;
+ return PIPE_OK;
}
void svga_update_state_retry( struct svga_context *svga,
unsigned max_level )
{
- int ret;
+ enum pipe_error ret;
ret = svga_update_state( svga, max_level );
ret = svga_update_state( svga, max_level );
}
- assert( ret == 0 );
+ assert( ret == PIPE_OK );
}
enum pipe_error ret;
ret = SVGA3D_BeginSetRenderState( svga->swc, &rs, COUNT );
- if (ret)
+ if (ret != PIPE_OK)
return ret;
/* Always use D3D style coordinate space as this is the only one
assert( COUNT == count );
SVGA_FIFOCommitAll( svga->swc );
- return 0;
-
+ return PIPE_OK;
}
struct svga_tracked_state {
const char *name;
unsigned dirty;
- int (*update)( struct svga_context *svga, unsigned dirty );
+ enum pipe_error (*update)( struct svga_context *svga, unsigned dirty );
};
/* NEED_SWTNL
/*
* Check and emit one shader constant register.
*/
-static int emit_const( struct svga_context *svga,
- int unit,
- int i,
- const float *value )
+static enum pipe_error
+emit_const(struct svga_context *svga, int unit, int i, const float *value)
{
- int ret = PIPE_OK;
+ enum pipe_error ret = PIPE_OK;
assert(i < CB_MAX);
svga_shader_type(unit),
SVGA3D_CONST_TYPE_FLOAT,
value );
- if (ret)
+ if (ret != PIPE_OK)
return ret;
memcpy(svga->state.hw_draw.cb[unit][i], value, 4 * sizeof(float));
return PIPE_OK;
}
-static int emit_consts( struct svga_context *svga,
- int offset,
- int unit )
+
+static enum pipe_error
+emit_consts(struct svga_context *svga, int offset, int unit)
{
struct svga_screen *ss = svga_screen(svga->pipe.screen);
struct pipe_transfer *transfer = NULL;
unsigned count;
const float (*data)[4] = NULL;
unsigned i;
- int ret = PIPE_OK;
+ enum pipe_error ret = PIPE_OK;
if (svga->curr.cb[unit] == NULL)
goto done;
return ret;
}
-
-static int emit_fs_consts( struct svga_context *svga,
- unsigned dirty )
+
+
+static enum pipe_error
+emit_fs_consts(struct svga_context *svga, unsigned dirty)
{
const struct svga_shader_result *result = svga->state.hw_draw.fs;
const struct svga_fs_compile_key *key = &result->key.fkey;
- int ret = 0;
+ enum pipe_error ret = PIPE_OK;
ret = emit_consts( svga, 0, PIPE_SHADER_FRAGMENT );
- if (ret)
+ if (ret != PIPE_OK)
return ret;
/* The internally generated fragment shader for xor blending
PIPE_SHADER_FRAGMENT,
key->tex[i].width_height_idx + offset,
data );
- if (ret)
+ if (ret != PIPE_OK)
return ret;
}
}
/***********************************************************************
*/
-static int emit_vs_consts( struct svga_context *svga,
- unsigned dirty )
+static enum pipe_error
+emit_vs_consts(struct svga_context *svga, unsigned dirty)
{
const struct svga_shader_result *result = svga->state.hw_draw.vs;
const struct svga_vs_compile_key *key = &result->key.vkey;
- int ret = 0;
+ enum pipe_error ret = PIPE_OK;
unsigned offset;
/* SVGA_NEW_VS_RESULT
*/
if (result == NULL)
- return 0;
+ return PIPE_OK;
/* SVGA_NEW_VS_CONST_BUFFER
*/
ret = emit_consts( svga, 0, PIPE_SHADER_VERTEX );
- if (ret)
+ if (ret != PIPE_OK)
return ret;
offset = result->shader->info.file_max[TGSI_FILE_CONSTANT] + 1;
if (key->need_prescale) {
ret = emit_const( svga, PIPE_SHADER_VERTEX, offset++,
svga->state.hw_clear.prescale.scale );
- if (ret)
+ if (ret != PIPE_OK)
return ret;
ret = emit_const( svga, PIPE_SHADER_VERTEX, offset++,
svga->state.hw_clear.prescale.translate );
- if (ret)
+ if (ret != PIPE_OK)
return ret;
}
ret = emit_const( svga, PIPE_SHADER_VERTEX, offset++,
svga->curr.zero_stride_constants +
4 * curr_zero_stride );
- if (ret)
+ if (ret != PIPE_OK)
return ret;
++curr_zero_stride;
}
}
}
- return 0;
+ return PIPE_OK;
}
SVGA3D_SHADERTYPE_PS,
result->tokens,
result->nr_tokens * sizeof result->tokens[0]);
- if (ret)
+ if (ret != PIPE_OK)
goto fail;
*out_result = result;
* SVGA_NEW_NEED_SWTNL
* SVGA_NEW_SAMPLER
*/
-static int make_fs_key( const struct svga_context *svga,
- struct svga_fs_compile_key *key )
+static enum pipe_error
+make_fs_key(const struct svga_context *svga,
+ struct svga_fs_compile_key *key)
{
int i;
int idx = 0;
key->sprite_origin_lower_left = (svga->curr.rast->templ.sprite_coord_mode
== PIPE_SPRITE_COORD_LOWER_LEFT);
- return 0;
+ return PIPE_OK;
}
-static int emit_hw_fs( struct svga_context *svga,
- unsigned dirty )
+static enum pipe_error
+emit_hw_fs(struct svga_context *svga, unsigned dirty)
{
struct svga_shader_result *result = NULL;
unsigned id = SVGA3D_INVALID_ID;
- int ret = 0;
+ enum pipe_error ret = PIPE_OK;
struct svga_fragment_shader *fs = svga->curr.fs;
struct svga_fs_compile_key key;
* SVGA_NEW_SAMPLER
*/
ret = make_fs_key( svga, &key );
- if (ret)
+ if (ret != PIPE_OK)
return ret;
result = search_fs_key( fs, &key );
if (!result) {
ret = compile_fs( svga, fs, &key, &result );
- if (ret)
+ if (ret != PIPE_OK)
return ret;
}
ret = SVGA3D_SetShader(svga->swc,
SVGA3D_SHADERTYPE_PS,
id );
- if (ret)
+ if (ret != PIPE_OK)
return ret;
svga->dirty |= SVGA_NEW_FS_RESULT;
svga->state.hw_draw.fs = result;
}
- return 0;
+ return PIPE_OK;
}
struct svga_tracked_state svga_hw_fs =
*/
-static int emit_hw_vs_vdecl( struct svga_context *svga,
- unsigned dirty )
+static enum pipe_error
+emit_hw_vs_vdecl(struct svga_context *svga, unsigned dirty)
{
const struct pipe_vertex_element *ve = svga->curr.velems->velem;
SVGA3dVertexDecl decl;
}
svga_hwtnl_set_index_bias( svga->hwtnl, -neg_bias );
- return 0;
+ return PIPE_OK;
}
-static int emit_hw_vdecl( struct svga_context *svga,
- unsigned dirty )
+static enum pipe_error
+emit_hw_vdecl(struct svga_context *svga, unsigned dirty)
{
/* SVGA_NEW_NEED_SWTNL
*/
if (svga->state.sw.need_swtnl)
- return 0; /* Do not emit during swtnl */
+ return PIPE_OK; /* Do not emit during swtnl */
return emit_hw_vs_vdecl( svga, dirty );
}
SVGA3D_SHADERTYPE_VS,
result->tokens,
result->nr_tokens * sizeof result->tokens[0]);
- if (ret)
+ if (ret != PIPE_OK)
goto fail;
*out_result = result;
/* SVGA_NEW_PRESCALE, SVGA_NEW_RAST, SVGA_NEW_ZERO_STRIDE
*/
-static int make_vs_key( struct svga_context *svga,
- struct svga_vs_compile_key *key )
+static void
+make_vs_key(struct svga_context *svga, struct svga_vs_compile_key *key)
{
memset(key, 0, sizeof *key);
key->need_prescale = svga->state.hw_clear.prescale.enabled;
svga->curr.zero_stride_vertex_elements;
key->num_zero_stride_vertex_elements =
svga->curr.num_zero_stride_vertex_elements;
- return 0;
}
-static int emit_hw_vs( struct svga_context *svga,
- unsigned dirty )
+static enum pipe_error
+emit_hw_vs(struct svga_context *svga, unsigned dirty)
{
struct svga_shader_result *result = NULL;
unsigned id = SVGA3D_INVALID_ID;
- int ret = 0;
+ enum pipe_error ret = PIPE_OK;
/* SVGA_NEW_NEED_SWTNL */
if (!svga->state.sw.need_swtnl) {
struct svga_vertex_shader *vs = svga->curr.vs;
struct svga_vs_compile_key key;
- ret = make_vs_key( svga, &key );
- if (ret)
- return ret;
+ make_vs_key( svga, &key );
result = search_vs_key( vs, &key );
if (!result) {
ret = compile_vs( svga, vs, &key, &result );
- if (ret)
+ if (ret != PIPE_OK)
return ret;
}
ret = SVGA3D_SetShader(svga->swc,
SVGA3D_SHADERTYPE_VS,
id );
- if (ret)
+ if (ret != PIPE_OK)
return ret;
svga->dirty |= SVGA_NEW_VS_RESULT;
svga->state.hw_draw.vs = result;
}
- return 0;
+ return PIPE_OK;
}
struct svga_tracked_state svga_hw_vs =
/* flush the hw state */
ret = svga_hwtnl_flush(svga->hwtnl);
- if (ret) {
+ if (ret != PIPE_OK) {
svga_context_flush(svga, NULL);
ret = svga_hwtnl_flush(svga->hwtnl);
/* if we hit this path we might become synced with hw */
struct svga_vbuf_render *svga_render = svga_vbuf_render(render);
struct svga_context *svga = svga_render->svga;
unsigned bias = (svga_render->vbuf_offset - svga_render->vdecl_offset) / svga_render->vertex_size;
- enum pipe_error ret = 0;
+ enum pipe_error ret = PIPE_OK;
/* off to hardware */
svga_vbuf_submit_state(svga_render);
svga->state.sw.in_swtnl_draw = TRUE;
ret = svga_update_state(svga, SVGA_STATE_SWTNL_DRAW);
- if (ret) {
+ if (ret != PIPE_OK) {
svga_context_flush(svga, NULL);
ret = svga_update_state(svga, SVGA_STATE_SWTNL_DRAW);
svga->swtnl.new_vbuf = TRUE;
{
struct svga_shader_result *result = NULL;
struct svga_shader_emitter emit;
- int ret = 0;
memset(&emit, 0, sizeof(emit));
emit.size = 1024;
emit.buf = MALLOC(emit.size);
if (emit.buf == NULL) {
- ret = PIPE_ERROR_OUT_OF_MEMORY;
goto fail;
}