Use NULL tests of the form `if (ptr)' or `if (!ptr)'.
They do not depend on the definition of the symbol NULL.
Further, they provide the opportunity for the accidental
assignment, are clear and succinct.
Signed-off-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
Signed-off-by: Marek Olšák <marek.olsak@amd.com>
54 files changed:
struct i915_context *i915;
i915 = CALLOC_STRUCT(i915_context);
struct i915_context *i915;
i915 = CALLOC_STRUCT(i915_context);
return NULL;
i915->iws = i915_screen(screen)->iws;
return NULL;
i915->iws = i915_screen(screen)->iws;
struct i915_buffer *buffer = i915_buffer(resource);
struct pipe_transfer *transfer = util_slab_alloc(&i915->transfer_pool);
struct i915_buffer *buffer = i915_buffer(resource);
struct pipe_transfer *transfer = util_slab_alloc(&i915->transfer_pool);
return NULL;
transfer->resource = resource;
return NULL;
transfer->resource = resource;
unsigned offset;
char *map;
unsigned offset;
char *map;
return NULL;
transfer->b.resource = resource;
return NULL;
transfer->b.resource = resource;
map = iws->buffer_map(iws, tex->buffer,
(transfer->b.usage & PIPE_TRANSFER_WRITE) ? TRUE : FALSE);
map = iws->buffer_map(iws, tex->buffer,
(transfer->b.usage & PIPE_TRANSFER_WRITE) ? TRUE : FALSE);
pipe_resource_reference(&transfer->staging_texture, NULL);
FREE(transfer);
return NULL;
pipe_resource_reference(&transfer->staging_texture, NULL);
FREE(transfer);
return NULL;
}
else {
struct data_block *block = MALLOC_STRUCT(data_block);
}
else {
struct data_block *block = MALLOC_STRUCT(data_block);
return NULL;
scene->scene_size += sizeof *block;
return NULL;
scene->scene_size += sizeof *block;
lp_scene_queue_create(void)
{
struct lp_scene_queue *queue = CALLOC_STRUCT(lp_scene_queue);
lp_scene_queue_create(void)
{
struct lp_scene_queue *queue = CALLOC_STRUCT(lp_scene_queue);
return NULL;
queue->ring = util_ringbuffer_create( MAX_SCENE_QUEUE *
return NULL;
queue->ring = util_ringbuffer_create( MAX_SCENE_QUEUE *
plane_sz);
tri = lp_scene_alloc_aligned( scene, *tri_size, 16 );
plane_sz);
tri = lp_scene_alloc_aligned( scene, *tri_size, 16 );
return NULL;
tri->inputs.stride = input_array_sz;
return NULL;
tri->inputs.stride = input_array_sz;
struct lp_geometry_shader *state;
state = CALLOC_STRUCT(lp_geometry_shader);
struct lp_geometry_shader *state;
state = CALLOC_STRUCT(lp_geometry_shader);
goto no_state;
/* debug */
goto no_state;
/* debug */
* handle, and what we'll look after ourselves.
*/
struct lp_rast_state *state = MALLOC_STRUCT(lp_rast_state);
* handle, and what we'll look after ourselves.
*/
struct lp_rast_state *state = MALLOC_STRUCT(lp_rast_state);
return NULL;
memcpy(&state->draw_state, rast, sizeof *rast);
return NULL;
memcpy(&state->draw_state, rast, sizeof *rast);
goto fail;
variant = CALLOC_STRUCT(lp_setup_variant);
goto fail;
variant = CALLOC_STRUCT(lp_setup_variant);
goto fail;
variant->no = setup_no++;
goto fail;
variant->no = setup_no++;
struct draw_vertex_shader *vs;
vs = draw_create_vertex_shader(llvmpipe->draw, templ);
struct draw_vertex_shader *vs;
vs = draw_create_vertex_shader(llvmpipe->draw, templ);
unsigned stride;
nresource = CALLOC_STRUCT(noop_resource);
unsigned stride;
nresource = CALLOC_STRUCT(noop_resource);
return NULL;
stride = util_format_get_stride(templ->format, templ->width0);
return NULL;
stride = util_format_get_stride(templ->format, templ->width0);
struct noop_resource *nresource = (struct noop_resource *)resource;
transfer = CALLOC_STRUCT(pipe_transfer);
struct noop_resource *nresource = (struct noop_resource *)resource;
transfer = CALLOC_STRUCT(pipe_transfer);
return NULL;
pipe_resource_reference(&transfer->resource, resource);
transfer->level = level;
return NULL;
pipe_resource_reference(&transfer->resource, resource);
transfer->level = level;
{
struct pipe_context *ctx = CALLOC_STRUCT(pipe_context);
{
struct pipe_context *ctx = CALLOC_STRUCT(pipe_context);
return NULL;
ctx->screen = screen;
ctx->priv = priv;
return NULL;
ctx->screen = screen;
ctx->priv = priv;
}
noop_screen = CALLOC_STRUCT(noop_pipe_screen);
}
noop_screen = CALLOC_STRUCT(noop_pipe_screen);
- if (noop_screen == NULL) {
return NULL;
}
noop_screen->oscreen = oscreen;
return NULL;
}
noop_screen->oscreen = oscreen;
{
struct pipe_blend_state *nstate = CALLOC_STRUCT(pipe_blend_state);
{
struct pipe_blend_state *nstate = CALLOC_STRUCT(pipe_blend_state);
return NULL;
}
*nstate = *state;
return NULL;
}
*nstate = *state;
{
struct pipe_depth_stencil_alpha_state *nstate = CALLOC_STRUCT(pipe_depth_stencil_alpha_state);
{
struct pipe_depth_stencil_alpha_state *nstate = CALLOC_STRUCT(pipe_depth_stencil_alpha_state);
return NULL;
}
*nstate = *state;
return NULL;
}
*nstate = *state;
{
struct pipe_rasterizer_state *nstate = CALLOC_STRUCT(pipe_rasterizer_state);
{
struct pipe_rasterizer_state *nstate = CALLOC_STRUCT(pipe_rasterizer_state);
return NULL;
}
*nstate = *state;
return NULL;
}
*nstate = *state;
{
struct pipe_sampler_state *nstate = CALLOC_STRUCT(pipe_sampler_state);
{
struct pipe_sampler_state *nstate = CALLOC_STRUCT(pipe_sampler_state);
return NULL;
}
*nstate = *state;
return NULL;
}
*nstate = *state;
{
struct pipe_sampler_view *sampler_view = CALLOC_STRUCT(pipe_sampler_view);
{
struct pipe_sampler_view *sampler_view = CALLOC_STRUCT(pipe_sampler_view);
- if (sampler_view == NULL)
return NULL;
/* initialize base object */
pipe_resource_reference(&sampler_view->texture, texture);
return NULL;
/* initialize base object */
pipe_resource_reference(&sampler_view->texture, texture);
{
struct pipe_surface *surface = CALLOC_STRUCT(pipe_surface);
{
struct pipe_surface *surface = CALLOC_STRUCT(pipe_surface);
return NULL;
pipe_reference_init(&surface->reference, 1);
pipe_resource_reference(&surface->texture, texture);
return NULL;
pipe_reference_init(&surface->reference, 1);
pipe_resource_reference(&surface->texture, texture);
{
struct pipe_vertex_element *nstate = CALLOC_STRUCT(pipe_vertex_element);
{
struct pipe_vertex_element *nstate = CALLOC_STRUCT(pipe_vertex_element);
return NULL;
}
*nstate = *state;
return NULL;
}
*nstate = *state;
{
struct pipe_shader_state *nstate = CALLOC_STRUCT(pipe_shader_state);
{
struct pipe_shader_state *nstate = CALLOC_STRUCT(pipe_shader_state);
return NULL;
}
*nstate = *state;
return NULL;
}
*nstate = *state;
else
f = fopen(filename, "r");
else
f = fopen(filename, "r");
_debug_printf("Error opening file '%s': %s\n", filename, strerror(errno));
return 1;
}
_debug_printf("Error opening file '%s': %s\n", filename, strerror(errno));
return 1;
}
STATIC_ASSERT(sizeof(struct mpeg12_header) == 0x100);
STATIC_ASSERT(sizeof(struct mpeg12_header) == 0x100);
ref2 = dest;
bo_refs[1].bo = ref1->interlaced;
bo_refs[2].bo = ref2->interlaced;
ref2 = dest;
bo_refs[1].bo = ref1->interlaced;
bo_refs[2].bo = ref2->interlaced;
if (inst->U.I.SrcReg[i].RelAddr &&
inst->U.I.SrcReg[i].Index < 0) {
/* ARL must precede any indirect addressing. */
if (inst->U.I.SrcReg[i].RelAddr &&
inst->U.I.SrcReg[i].Index < 0) {
/* ARL must precede any indirect addressing. */
rc_error(&c->Base, "Vertex shader: Found relative addressing without ARL/ARR.");
return;
}
rc_error(&c->Base, "Vertex shader: Found relative addressing without ARL/ARR.");
return;
}
map = rws->buffer_map(rbuf->cs_buf, r300->cs, usage);
map = rws->buffer_map(rbuf->cs_buf, r300->cs, usage);
util_slab_free(&r300->pool_transfers, transfer);
return NULL;
}
util_slab_free(&r300->pool_transfers, transfer);
return NULL;
}
struct r300_context* r300 = r300_context(pipe);
struct r300_fragment_shader* fs = (struct r300_fragment_shader*)shader;
struct r300_context* r300 = r300_context(pipe);
struct r300_fragment_shader* fs = (struct r300_fragment_shader*)shader;
r300->fs.state = NULL;
return;
}
r300->fs.state = NULL;
return;
}
struct r300_context *r300 = r300_context(pipe);
struct r300_vertex_element_state *velems = state;
struct r300_context *r300 = r300_context(pipe);
struct r300_vertex_element_state *velems = state;
struct r300_context* r300 = r300_context(pipe);
struct r300_vertex_shader* vs = (struct r300_vertex_shader*)shader;
struct r300_context* r300 = r300_context(pipe);
struct r300_vertex_shader* vs = (struct r300_vertex_shader*)shader;
r300->vs_state.state = NULL;
return;
}
r300->vs_state.state = NULL;
return;
}
{
struct compute_memory_pool* pool = (struct compute_memory_pool*)
CALLOC(sizeof(struct compute_memory_pool), 1);
{
struct compute_memory_pool* pool = (struct compute_memory_pool*)
CALLOC(sizeof(struct compute_memory_pool), 1);
return NULL;
COMPUTE_DBG(rscreen, "* compute_memory_pool_new()\n");
return NULL;
COMPUTE_DBG(rscreen, "* compute_memory_pool_new()\n");
list_addtail(&item->link, pool->item_list);
item->start_in_dw = start_in_dw;
list_addtail(&item->link, pool->item_list);
item->start_in_dw = start_in_dw;
u_box_1d(0, item->size_in_dw * 4, &box);
rctx->b.b.resource_copy_region(pipe,
u_box_1d(0, item->size_in_dw * 4, &box);
rctx->b.b.resource_copy_region(pipe,
new_item = (struct compute_memory_item *)
CALLOC(sizeof(struct compute_memory_item), 1);
new_item = (struct compute_memory_item *)
CALLOC(sizeof(struct compute_memory_item), 1);
return NULL;
new_item->size_in_dw = size_in_dw;
return NULL;
new_item->size_in_dw = size_in_dw;
unsigned db_depth_control, alpha_test_control, alpha_ref;
struct r600_dsa_state *dsa = CALLOC_STRUCT(r600_dsa_state);
unsigned db_depth_control, alpha_test_control, alpha_ref;
struct r600_dsa_state *dsa = CALLOC_STRUCT(r600_dsa_state);
float psize_min, psize_max;
struct r600_rasterizer_state *rs = CALLOC_STRUCT(r600_rasterizer_state);
float psize_min, psize_max;
struct r600_rasterizer_state *rs = CALLOC_STRUCT(r600_rasterizer_state);
struct r600_pipe_sampler_state *ss = CALLOC_STRUCT(r600_pipe_sampler_state);
unsigned aniso_flag_offset = state->max_anisotropy > 1 ? 2 : 0;
struct r600_pipe_sampler_state *ss = CALLOC_STRUCT(r600_pipe_sampler_state);
unsigned aniso_flag_offset = state->max_anisotropy > 1 ? 2 : 0;
unsigned dim, last_layer;
uint64_t va;
unsigned dim, last_layer;
uint64_t va;
return NULL;
/* initialize base object */
return NULL;
/* initialize base object */
{
struct r600_bytecode_cf *cf = CALLOC_STRUCT(r600_bytecode_cf);
{
struct r600_bytecode_cf *cf = CALLOC_STRUCT(r600_bytecode_cf);
return NULL;
LIST_INITHEAD(&cf->list);
LIST_INITHEAD(&cf->alu);
return NULL;
LIST_INITHEAD(&cf->list);
LIST_INITHEAD(&cf->alu);
{
struct r600_bytecode_alu *alu = CALLOC_STRUCT(r600_bytecode_alu);
{
struct r600_bytecode_alu *alu = CALLOC_STRUCT(r600_bytecode_alu);
return NULL;
LIST_INITHEAD(&alu->list);
return alu;
return NULL;
LIST_INITHEAD(&alu->list);
return alu;
{
struct r600_bytecode_vtx *vtx = CALLOC_STRUCT(r600_bytecode_vtx);
{
struct r600_bytecode_vtx *vtx = CALLOC_STRUCT(r600_bytecode_vtx);
return NULL;
LIST_INITHEAD(&vtx->list);
return vtx;
return NULL;
LIST_INITHEAD(&vtx->list);
return vtx;
{
struct r600_bytecode_tex *tex = CALLOC_STRUCT(r600_bytecode_tex);
{
struct r600_bytecode_tex *tex = CALLOC_STRUCT(r600_bytecode_tex);
return NULL;
LIST_INITHEAD(&tex->list);
return tex;
return NULL;
LIST_INITHEAD(&tex->list);
return tex;
{
struct r600_bytecode_cf *cf = r600_bytecode_cf();
{
struct r600_bytecode_cf *cf = r600_bytecode_cf();
return -ENOMEM;
LIST_ADDTAIL(&cf->list, &bc->cf);
if (bc->cf_last) {
return -ENOMEM;
LIST_ADDTAIL(&cf->list, &bc->cf);
if (bc->cf_last) {
struct r600_bytecode_alu *lalu;
int i, r;
struct r600_bytecode_alu *lalu;
int i, r;
return -ENOMEM;
memcpy(nalu, alu, sizeof(struct r600_bytecode_alu));
return -ENOMEM;
memcpy(nalu, alu, sizeof(struct r600_bytecode_alu));
struct r600_bytecode_vtx *nvtx = r600_bytecode_vtx();
int r;
struct r600_bytecode_vtx *nvtx = r600_bytecode_vtx();
int r;
return -ENOMEM;
memcpy(nvtx, vtx, sizeof(struct r600_bytecode_vtx));
return -ENOMEM;
memcpy(nvtx, vtx, sizeof(struct r600_bytecode_vtx));
struct r600_bytecode_tex *ntex = r600_bytecode_tex();
int r;
struct r600_bytecode_tex *ntex = r600_bytecode_tex();
int r;
return -ENOMEM;
memcpy(ntex, tex, sizeof(struct r600_bytecode_tex));
return -ENOMEM;
memcpy(ntex, tex, sizeof(struct r600_bytecode_tex));
&format, &num_format, &format_comp, &endian);
desc = util_format_description(elements[i].src_format);
&format, &num_format, &format_comp, &endian);
desc = util_format_description(elements[i].src_format);
r600_bytecode_clear(&bc);
R600_ERR("unknown format %d\n", elements[i].src_format);
return NULL;
r600_bytecode_clear(&bc);
R600_ERR("unknown format %d\n", elements[i].src_format);
return NULL;
struct r600_screen* rscreen = (struct r600_screen *)screen;
struct radeon_winsys *ws = rscreen->b.ws;
struct r600_screen* rscreen = (struct r600_screen *)screen;
struct radeon_winsys *ws = rscreen->b.ws;
return NULL;
rctx->b.b.screen = screen;
return NULL;
rctx->b.b.screen = screen;
{
struct r600_screen *rscreen = (struct r600_screen *)pscreen;
{
struct r600_screen *rscreen = (struct r600_screen *)pscreen;
return;
if (!rscreen->b.ws->unref(rscreen->b.ws))
return;
if (!rscreen->b.ws->unref(rscreen->b.ws))
{
struct r600_screen *rscreen = CALLOC_STRUCT(r600_screen);
{
struct r600_screen *rscreen = CALLOC_STRUCT(r600_screen);
unsigned db_depth_control, alpha_test_control, alpha_ref;
struct r600_dsa_state *dsa = CALLOC_STRUCT(r600_dsa_state);
unsigned db_depth_control, alpha_test_control, alpha_ref;
struct r600_dsa_state *dsa = CALLOC_STRUCT(r600_dsa_state);
float psize_min, psize_max;
struct r600_rasterizer_state *rs = CALLOC_STRUCT(r600_rasterizer_state);
float psize_min, psize_max;
struct r600_rasterizer_state *rs = CALLOC_STRUCT(r600_rasterizer_state);
struct r600_pipe_sampler_state *ss = CALLOC_STRUCT(r600_pipe_sampler_state);
unsigned aniso_flag_offset = state->max_anisotropy > 1 ? 4 : 0;
struct r600_pipe_sampler_state *ss = CALLOC_STRUCT(r600_pipe_sampler_state);
unsigned aniso_flag_offset = state->max_anisotropy > 1 ? 4 : 0;
unsigned char swizzle[4], array_mode = 0;
unsigned width, height, depth, offset_level, last_level;
unsigned char swizzle[4], array_mode = 0;
unsigned width, height, depth, offset_level, last_level;
return NULL;
/* initialize base object */
return NULL;
/* initialize base object */
struct r600_context *rctx = (struct r600_context *)ctx;
struct r600_blend_state *blend = (struct r600_blend_state *)state;
struct r600_context *rctx = (struct r600_context *)ctx;
struct r600_blend_state *blend = (struct r600_blend_state *)state;
r600_set_cso_state_with_cb(rctx, &rctx->blend_state, NULL, NULL);
return;
}
r600_set_cso_state_with_cb(rctx, &rctx->blend_state, NULL, NULL);
return;
}
struct r600_dsa_state *dsa = state;
struct r600_stencil_ref ref;
struct r600_dsa_state *dsa = state;
struct r600_stencil_ref ref;
r600_set_cso_state_with_cb(rctx, &rctx->dsa_state, NULL, NULL);
return;
}
r600_set_cso_state_with_cb(rctx, &rctx->dsa_state, NULL, NULL);
return;
}
struct r600_rasterizer_state *rs = (struct r600_rasterizer_state *)state;
struct r600_context *rctx = (struct r600_context *)ctx;
struct r600_rasterizer_state *rs = (struct r600_rasterizer_state *)state;
struct r600_context *rctx = (struct r600_context *)ctx;
return;
rctx->rasterizer = rs;
return;
rctx->rasterizer = rs;
struct r600_common_context *rctx = (struct r600_common_context *)ctx;
struct r600_resource *rr = (struct r600_resource *)r;
struct r600_common_context *rctx = (struct r600_common_context *)ctx;
struct r600_resource *rr = (struct r600_resource *)r;
struct r600_query_sw *query;
query = CALLOC_STRUCT(r600_query_sw);
struct r600_query_sw *query;
query = CALLOC_STRUCT(r600_query_sw);
return NULL;
query->b.type = query_type;
return NULL;
query->b.type = query_type;
struct r600_common_screen *rscreen = (struct r600_common_screen*)screen;
rtex = CALLOC_STRUCT(r600_texture);
struct r600_common_screen *rscreen = (struct r600_common_screen*)screen;
rtex = CALLOC_STRUCT(r600_texture);
return NULL;
resource = &rtex->resource;
return NULL;
resource = &rtex->resource;
}
trans = CALLOC_STRUCT(r600_transfer);
}
trans = CALLOC_STRUCT(r600_transfer);
return NULL;
trans->transfer.resource = texture;
trans->transfer.level = level;
return NULL;
trans->transfer.resource = texture;
trans->transfer.level = level;
/* Create the temporary texture. */
staging = (struct r600_texture*)ctx->screen->resource_create(ctx->screen, &resource);
/* Create the temporary texture. */
staging = (struct r600_texture*)ctx->screen->resource_create(ctx->screen, &resource);
R600_ERR("failed to create temporary texture to hold untiled copy\n");
FREE(trans);
return NULL;
R600_ERR("failed to create temporary texture to hold untiled copy\n");
FREE(trans);
return NULL;
{
struct r600_surface *surface = CALLOC_STRUCT(r600_surface);
{
struct r600_surface *surface = CALLOC_STRUCT(r600_surface);
return NULL;
assert(templ->u.tex.first_layer <= util_max_layer(texture, templ->u.tex.level));
return NULL;
assert(templ->u.tex.first_layer <= util_max_layer(texture, templ->u.tex.level));
vb = &sctx->vertex_buffer[ve->vertex_buffer_index];
rbuffer = (struct r600_resource*)vb->buffer;
vb = &sctx->vertex_buffer[ve->vertex_buffer_index];
rbuffer = (struct r600_resource*)vb->buffer;
memset(desc, 0, 16);
continue;
}
memset(desc, 0, 16);
continue;
}
return NULL;
if (sscreen->b.debug_flags & DBG_CHECK_VM)
return NULL;
if (sscreen->b.debug_flags & DBG_CHECK_VM)
{
struct si_screen *sscreen = (struct si_screen *)pscreen;
{
struct si_screen *sscreen = (struct si_screen *)pscreen;
return;
if (!sscreen->b.ws->unref(sscreen->b.ws))
return;
if (!sscreen->b.ws->unref(sscreen->b.ws))
{
struct si_screen *sscreen = CALLOC_STRUCT(si_screen);
{
struct si_screen *sscreen = CALLOC_STRUCT(si_screen);
struct si_pm4_state *state,
unsigned idx)
{
struct si_pm4_state *state,
unsigned idx)
{
return;
if (idx != ~0 && sctx->emitted.array[idx] == state) {
return;
if (idx != ~0 && sctx->emitted.array[idx] == state) {
uint32_t color_control = 0;
uint32_t color_control = 0;
return NULL;
blend->alpha_to_one = state->alpha_to_one;
return NULL;
blend->alpha_to_one = state->alpha_to_one;
unsigned tmp, i;
float psize_min, psize_max;
unsigned tmp, i;
float psize_min, psize_max;
(struct si_state_rasterizer*)sctx->queued.named.rasterizer;
struct si_state_rasterizer *rs = (struct si_state_rasterizer *)state;
(struct si_state_rasterizer*)sctx->queued.named.rasterizer;
struct si_state_rasterizer *rs = (struct si_state_rasterizer *)state;
return;
if (sctx->framebuffer.nr_samples > 1 &&
return;
if (sctx->framebuffer.nr_samples > 1 &&
unsigned db_depth_control;
uint32_t db_stencil_control = 0;
unsigned db_depth_control;
uint32_t db_stencil_control = 0;
struct si_context *sctx = (struct si_context *)ctx;
struct si_state_dsa *dsa = state;
struct si_context *sctx = (struct si_context *)ctx;
struct si_state_dsa *dsa = state;
return;
si_pm4_bind_state(sctx, dsa, dsa);
return;
si_pm4_bind_state(sctx, dsa, dsa);
uint64_t va;
unsigned last_layer = state->u.tex.last_layer;
uint64_t va;
unsigned last_layer = state->u.tex.last_layer;
return NULL;
/* initialize base object */
return NULL;
/* initialize base object */
unsigned aniso_flag_offset = state->max_anisotropy > 1 ? 2 : 0;
unsigned border_color_type, border_color_index = 0;
unsigned aniso_flag_offset = state->max_anisotropy > 1 ? 2 : 0;
unsigned border_color_type, border_color_index = 0;
struct si_pm4_state *pm4 = CALLOC_STRUCT(si_pm4_state);
int i;
struct si_pm4_state *pm4 = CALLOC_STRUCT(si_pm4_state);
int i;
return;
si_pm4_cmd_begin(pm4, PKT3_CONTEXT_CONTROL);
return;
si_pm4_cmd_begin(pm4, PKT3_CONTEXT_CONTROL);
uint64_t va;
pm4 = shader->pm4 = CALLOC_STRUCT(si_pm4_state);
uint64_t va;
pm4 = shader->pm4 = CALLOC_STRUCT(si_pm4_state);
return;
va = shader->bo->gpu_address;
return;
va = shader->bo->gpu_address;
uint64_t va;
pm4 = shader->pm4 = CALLOC_STRUCT(si_pm4_state);
uint64_t va;
pm4 = shader->pm4 = CALLOC_STRUCT(si_pm4_state);
return;
va = shader->bo->gpu_address;
return;
va = shader->bo->gpu_address;
pm4 = shader->pm4 = CALLOC_STRUCT(si_pm4_state);
pm4 = shader->pm4 = CALLOC_STRUCT(si_pm4_state);
return;
va = shader->bo->gpu_address;
return;
va = shader->bo->gpu_address;
pm4 = shader->pm4 = CALLOC_STRUCT(si_pm4_state);
pm4 = shader->pm4 = CALLOC_STRUCT(si_pm4_state);
return;
if (gs_max_vert_out <= 128) {
return;
if (gs_max_vert_out <= 128) {
pm4 = shader->pm4 = CALLOC_STRUCT(si_pm4_state);
pm4 = shader->pm4 = CALLOC_STRUCT(si_pm4_state);
return;
/* If this is the GS copy shader, the GS state writes this register.
return;
/* If this is the GS copy shader, the GS state writes this register.
pm4 = shader->pm4 = CALLOC_STRUCT(si_pm4_state);
pm4 = shader->pm4 = CALLOC_STRUCT(si_pm4_state);
return;
for (i = 0; i < info->num_inputs; i++) {
return;
for (i = 0; i < info->num_inputs; i++) {
struct sp_vertex_shader *state;
state = CALLOC_STRUCT(sp_vertex_shader);
struct sp_vertex_shader *state;
state = CALLOC_STRUCT(sp_vertex_shader);
goto fail;
/* copy shader tokens, the ones passed in will go away.
goto fail;
/* copy shader tokens, the ones passed in will go away.
struct sp_geometry_shader *state;
state = CALLOC_STRUCT(sp_geometry_shader);
struct sp_geometry_shader *state;
state = CALLOC_STRUCT(sp_geometry_shader);
goto fail;
state->shader = *templ;
goto fail;
state->shader = *templ;
pipe_resource_reference(&pt->resource, NULL);
FREE(spt);
return NULL;
pipe_resource_reference(&pt->resource, NULL);
FREE(spt);
return NULL;
SVGA_3D_CMD_BEGIN_GB_QUERY,
sizeof *cmd,
1);
SVGA_3D_CMD_BEGIN_GB_QUERY,
sizeof *cmd,
1);
return PIPE_ERROR_OUT_OF_MEMORY;
cmd->cid = swc->cid;
return PIPE_ERROR_OUT_OF_MEMORY;
cmd->cid = swc->cid;
SVGA_3D_CMD_END_GB_QUERY,
sizeof *cmd,
2);
SVGA_3D_CMD_END_GB_QUERY,
sizeof *cmd,
2);
return PIPE_ERROR_OUT_OF_MEMORY;
cmd->cid = swc->cid;
return PIPE_ERROR_OUT_OF_MEMORY;
cmd->cid = swc->cid;
SVGA_3D_CMD_WAIT_FOR_GB_QUERY,
sizeof *cmd,
2);
SVGA_3D_CMD_WAIT_FOR_GB_QUERY,
sizeof *cmd,
2);
return PIPE_ERROR_OUT_OF_MEMORY;
cmd->cid = swc->cid;
return PIPE_ERROR_OUT_OF_MEMORY;
cmd->cid = swc->cid;
enum pipe_error ret;
svga = CALLOC_STRUCT(svga_context);
enum pipe_error ret;
svga = CALLOC_STRUCT(svga_context);
goto cleanup;
LIST_INITHEAD(&svga->dirty_buffers);
goto cleanup;
LIST_INITHEAD(&svga->dirty_buffers);
PIPE_TIMEOUT_INFINITE);
}
PIPE_TIMEOUT_INFINITE);
}
svgascreen->sws->fence_reference(svgascreen->sws, pfence, fence);
svgascreen->sws->fence_reference(svgascreen->sws, &fence, NULL);
svgascreen->sws->fence_reference(svgascreen->sws, pfence, fence);
svgascreen->sws->fence_reference(svgascreen->sws, &fence, NULL);
svga_hwtnl_create(struct svga_context *svga)
{
struct svga_hwtnl *hwtnl = CALLOC_STRUCT(svga_hwtnl);
svga_hwtnl_create(struct svga_context *svga)
{
struct svga_hwtnl *hwtnl = CALLOC_STRUCT(svga_hwtnl);
goto fail;
hwtnl->svga = svga;
goto fail;
hwtnl->svga = svga;
for (i = 0; i < hwtnl->cmd.vdecl_count; i++) {
unsigned j = hwtnl->cmd.vdecl_buffer_index[i];
handle = svga_buffer_handle(svga, hwtnl->cmd.vbufs[j].buffer);
for (i = 0; i < hwtnl->cmd.vdecl_count; i++) {
unsigned j = hwtnl->cmd.vdecl_buffer_index[i];
handle = svga_buffer_handle(svga, hwtnl->cmd.vbufs[j].buffer);
return PIPE_ERROR_OUT_OF_MEMORY;
vb_handle[i] = handle;
return PIPE_ERROR_OUT_OF_MEMORY;
vb_handle[i] = handle;
for (i = 0; i < hwtnl->cmd.prim_count; i++) {
if (hwtnl->cmd.prim_ib[i]) {
handle = svga_buffer_handle(svga, hwtnl->cmd.prim_ib[i]);
for (i = 0; i < hwtnl->cmd.prim_count; i++) {
if (hwtnl->cmd.prim_ib[i]) {
handle = svga_buffer_handle(svga, hwtnl->cmd.prim_ib[i]);
return PIPE_ERROR_OUT_OF_MEMORY;
}
else
return PIPE_ERROR_OUT_OF_MEMORY;
}
else
(void) sbuf; /* silence unused var warning */
ib_handle = svga_buffer_handle(svga, ib);
(void) sbuf; /* silence unused var warning */
ib_handle = svga_buffer_handle(svga, ib);
return PIPE_ERROR_OUT_OF_MEMORY;
}
else {
return PIPE_ERROR_OUT_OF_MEMORY;
}
else {
dst = pipe_buffer_create(pipe->screen, PIPE_BIND_INDEX_BUFFER,
PIPE_USAGE_IMMUTABLE, size);
dst = pipe_buffer_create(pipe->screen, PIPE_BIND_INDEX_BUFFER,
PIPE_USAGE_IMMUTABLE, size);
goto fail;
dst_map = pipe_buffer_map(pipe, dst, PIPE_TRANSFER_WRITE, &transfer);
goto fail;
dst_map = pipe_buffer_map(pipe, dst, PIPE_TRANSFER_WRITE, &transfer);
goto fail;
generate(0, nr, dst_map);
goto fail;
generate(0, nr, dst_map);
dst = pipe_buffer_create(pipe->screen,
PIPE_BIND_INDEX_BUFFER, PIPE_USAGE_DEFAULT, size);
dst = pipe_buffer_create(pipe->screen,
PIPE_BIND_INDEX_BUFFER, PIPE_USAGE_DEFAULT, size);
goto fail;
src_map = pipe_buffer_map(pipe, src, PIPE_TRANSFER_READ, &src_transfer);
goto fail;
src_map = pipe_buffer_map(pipe, src, PIPE_TRANSFER_READ, &src_transfer);
goto fail;
dst_map = pipe_buffer_map(pipe, dst, PIPE_TRANSFER_WRITE, &dst_transfer);
goto fail;
dst_map = pipe_buffer_map(pipe, dst, PIPE_TRANSFER_WRITE, &dst_transfer);
goto fail;
translate((const char *) src_map + offset, 0, 0, nr, 0, dst_map);
goto fail;
translate((const char *) src_map + offset, 0, 0, nr, 0, dst_map);
rtv = svga_validate_surface_view(svga,
svga_surface(fb->cbufs[i]));
rtv = svga_validate_surface_view(svga,
svga_surface(fb->cbufs[i]));
return PIPE_ERROR_OUT_OF_MEMORY;
ret = SVGA3D_vgpu10_ClearRenderTargetView(svga->swc,
return PIPE_ERROR_OUT_OF_MEMORY;
ret = SVGA3D_vgpu10_ClearRenderTargetView(svga->swc,
if (flags & (SVGA3D_CLEAR_DEPTH | SVGA3D_CLEAR_STENCIL)) {
struct pipe_surface *dsv =
svga_validate_surface_view(svga, svga_surface(fb->zsbuf));
if (flags & (SVGA3D_CLEAR_DEPTH | SVGA3D_CLEAR_STENCIL)) {
struct pipe_surface *dsv =
svga_validate_surface_view(svga, svga_surface(fb->zsbuf));
return PIPE_ERROR_OUT_OF_MEMORY;
ret = SVGA3D_vgpu10_ClearDepthStencilView(svga->swc, dsv, flags,
return PIPE_ERROR_OUT_OF_MEMORY;
ret = SVGA3D_vgpu10_ClearDepthStencilView(svga->swc, dsv, flags,
if (block_index == -1)
return NULL;
alloc_entry = CALLOC_STRUCT(svga_qmem_alloc_entry);
if (block_index == -1)
return NULL;
alloc_entry = CALLOC_STRUCT(svga_qmem_alloc_entry);
- if (alloc_entry == NULL)
return NULL;
alloc_entry->block_index = block_index;
return NULL;
alloc_entry->block_index = block_index;
alloc_entry = svga->gb_query_map[type];
alloc_entry = svga->gb_query_map[type];
- if (alloc_entry == NULL) {
/**
* No query memory block has been allocated for this query type,
* allocate one now
*/
alloc_entry = allocate_query_block_entry(svga, len);
/**
* No query memory block has been allocated for this query type,
* allocate one now
*/
alloc_entry = allocate_query_block_entry(svga, len);
- if (alloc_entry == NULL)
return -1;
svga->gb_query_map[type] = alloc_entry;
}
return -1;
svga->gb_query_map[type] = alloc_entry;
}
if (slot_index == -1) {
/* This query memory block is full, allocate another one */
alloc_entry = allocate_query_block_entry(svga, len);
if (slot_index == -1) {
/* This query memory block is full, allocate another one */
alloc_entry = allocate_query_block_entry(svga, len);
- if (alloc_entry == NULL)
return -1;
alloc_entry->next = svga->gb_query_map[type];
svga->gb_query_map[type] = alloc_entry;
return -1;
alloc_entry->next = svga->gb_query_map[type];
svga->gb_query_map[type] = alloc_entry;
struct svga_winsys_screen *sws = svga_screen(svga->pipe.screen)->sws;
struct svga_query *sq;
struct svga_winsys_screen *sws = svga_screen(svga->pipe.screen)->sws;
struct svga_query *sq;
destroy_gb_query_obj(svga);
return;
}
destroy_gb_query_obj(svga);
return;
}
/* Allocate the streamout data structure */
streamout = CALLOC_STRUCT(svga_stream_output);
/* Allocate the streamout data structure */
streamout = CALLOC_STRUCT(svga_stream_output);
return NULL;
streamout->info = *info;
return NULL;
streamout->info = *info;
assert(box->depth == 1);
transfer = CALLOC_STRUCT(pipe_transfer);
assert(box->depth == 1);
transfer = CALLOC_STRUCT(pipe_transfer);
- if (transfer == NULL) {
/*
* Make sure we return NULL if the map fails
*/
/*
* Make sure we return NULL if the map fails
*/
data = (const float (*)[4])
pipe_buffer_map(&svga->pipe, svga->curr.constbufs[shader][0].buffer,
PIPE_TRANSFER_READ, &transfer);
data = (const float (*)[4])
pipe_buffer_map(&svga->pipe, svga->curr.constbufs[shader][0].buffer,
PIPE_TRANSFER_READ, &transfer);
return PIPE_ERROR_OUT_OF_MEMORY;
}
return PIPE_ERROR_OUT_OF_MEMORY;
}
/* SVGA_NEW_FS_VARIANT
*/
/* SVGA_NEW_FS_VARIANT
*/
return PIPE_OK;
/* SVGA_NEW_FS_CONST_BUFFER
return PIPE_OK;
/* SVGA_NEW_FS_CONST_BUFFER
/* SVGA_NEW_VS_VARIANT
*/
/* SVGA_NEW_VS_VARIANT
*/
return PIPE_OK;
/* SVGA_NEW_VS_CONST_BUFFER
return PIPE_OK;
/* SVGA_NEW_VS_CONST_BUFFER
/* SVGA_NEW_GS_VARIANT
*/
/* SVGA_NEW_GS_VARIANT
*/
return PIPE_OK;
/* SVGA_NEW_GS_CONST_BUFFER
return PIPE_OK;
/* SVGA_NEW_GS_CONST_BUFFER
/* Setup depth stencil view */
if (curr->zsbuf) {
dsv = svga_validate_surface_view(svga, svga_surface(curr->zsbuf));
/* Setup depth stencil view */
if (curr->zsbuf) {
dsv = svga_validate_surface_view(svga, svga_surface(curr->zsbuf));
return PIPE_ERROR_OUT_OF_MEMORY;
}
}
return PIPE_ERROR_OUT_OF_MEMORY;
}
}
enum pipe_error ret = PIPE_ERROR;
variant = translate_geometry_program(svga, gs, key);
enum pipe_error ret = PIPE_ERROR;
variant = translate_geometry_program(svga, gs, key);
/* some problem during translation, try the dummy shader */
const struct tgsi_token *dummy = get_dummy_geometry_shader();
if (!dummy) {
/* some problem during translation, try the dummy shader */
const struct tgsi_token *dummy = get_dummy_geometry_shader();
if (!dummy) {
FREE((void *) gs->base.tokens);
gs->base.tokens = dummy;
variant = translate_geometry_program(svga, gs, key);
FREE((void *) gs->base.tokens);
gs->base.tokens = dummy;
variant = translate_geometry_program(svga, gs, key);
if (svga->curr.user_gs)
assert(svga->curr.gs);
if (svga->curr.user_gs)
assert(svga->curr.gs);
if (svga->state.hw_draw.gs != NULL) {
/** The previous geometry shader is made inactive.
if (svga->state.hw_draw.gs != NULL) {
/** The previous geometry shader is made inactive.
key.gs.aa_point = svga->curr.rast->templ.point_smooth;
key.gs.aa_point = svga->curr.rast->templ.point_smooth;
/* Check if the original geometry shader has stream output and
* if position is one of the outputs.
*/
streamout = orig_gs->base.stream_output;
/* Check if the original geometry shader has stream output and
* if position is one of the outputs.
*/
streamout = orig_gs->base.stream_output;
- if (streamout != NULL) {
pos_out_index = streamout->pos_out_index;
key.gs.point_pos_stream_out = pos_out_index != -1;
}
pos_out_index = streamout->pos_out_index;
key.gs.point_pos_stream_out = pos_out_index != -1;
}
key.gs.aa_point ?
&aa_point_coord_index : NULL);
key.gs.aa_point ?
&aa_point_coord_index : NULL);
- if (new_tokens == NULL) {
/* if no new tokens are generated for whatever reason, just return */
return NULL;
}
/* if no new tokens are generated for whatever reason, just return */
return NULL;
}
templ.tokens = new_tokens;
templ.stream_output.num_outputs = 0;
templ.tokens = new_tokens;
templ.stream_output.num_outputs = 0;
- if (streamout != NULL) {
templ.stream_output = streamout->info;
/* The tgsi_add_point_sprite utility adds an extra output
* for the original point position for stream output purpose.
templ.stream_output = streamout->info;
/* The tgsi_add_point_sprite utility adds an extra output
* for the original point position for stream output purpose.
/* Add the new geometry shader to the head of the shader list
* pointed to by the original geometry shader.
*/
/* Add the new geometry shader to the head of the shader list
* pointed to by the original geometry shader.
*/
gs->base.next = orig_gs->base.next;
orig_gs->base.next = &gs->base;
}
gs->base.next = orig_gs->base.next;
orig_gs->base.next = &gs->base;
}
vs->base.info.output_semantic_name,
vs->base.info.output_semantic_index);
vs->base.info.output_semantic_name,
vs->base.info.output_semantic_index);
{
struct svga_surface *bs = s->backed;
{
struct svga_surface *bs = s->backed;
struct svga_texture *tex = svga_texture(s->base.texture);
struct pipe_surface *backed_view;
struct svga_texture *tex = svga_texture(s->base.texture);
struct pipe_surface *backed_view;
emit->ptr = err_buf;
emit->buf = err_buf;
emit->size = sizeof(err_buf);
emit->ptr = err_buf;
emit->buf = err_buf;
emit->size = sizeof(err_buf);
}
variant = svga_new_shader_variant(svga);
}
variant = svga_new_shader_variant(svga);
goto fail;
variant->shader = shader;
goto fail;
variant->shader = shader;
emit->ptr = err_buf;
emit->buf = err_buf;
emit->size = sizeof(err_buf);
emit->ptr = err_buf;
emit->buf = err_buf;
emit->size = sizeof(err_buf);
vc4_debug &= ~VC4_DEBUG_SHADERDB;
vc4 = rzalloc(NULL, struct vc4_context);
vc4_debug &= ~VC4_DEBUG_SHADERDB;
vc4 = rzalloc(NULL, struct vc4_context);
return NULL;
struct pipe_context *pctx = &vc4->base;
return NULL;
struct pipe_context *pctx = &vc4->base;
ctx->flush(ctx, NULL, 0);
trans = util_slab_alloc(&vctx->texture_transfer_pool);
ctx->flush(ctx, NULL, 0);
trans = util_slab_alloc(&vctx->texture_transfer_pool);
return NULL;
trans->base.resource = resource;
return NULL;
trans->base.resource = resource;
uint32_t handle;
surf = CALLOC_STRUCT(virgl_surface);
uint32_t handle;
surf = CALLOC_STRUCT(virgl_surface);
return NULL;
res->clean = FALSE;
return NULL;
res->clean = FALSE;
uint32_t handle;
struct virgl_resource *res;
uint32_t handle;
struct virgl_resource *res;
return NULL;
grview = CALLOC_STRUCT(virgl_sampler_view);
return NULL;
grview = CALLOC_STRUCT(virgl_sampler_view);
ctx->flush(ctx, NULL, 0);
trans = util_slab_alloc(&vctx->texture_transfer_pool);
ctx->flush(ctx, NULL, 0);
trans = util_slab_alloc(&vctx->texture_transfer_pool);
return NULL;
trans->base.resource = resource;
return NULL;
trans->base.resource = resource;