surf = vctx->framebuffer.zsbuf;
if (surf) {
- res = (struct virgl_resource *)surf->texture;
+ res = virgl_resource(surf->texture);
if (res)
vws->emit_res(vws, vctx->cbuf, res->hw_res, FALSE);
}
for (i = 0; i < vctx->framebuffer.nr_cbufs; i++) {
surf = vctx->framebuffer.cbufs[i];
if (surf) {
- res = (struct virgl_resource *)surf->texture;
+ res = virgl_resource(surf->texture);
if (res)
vws->emit_res(vws, vctx->cbuf, res->hw_res, FALSE);
}
i = u_bit_scan(&remaining_mask);
assert(tinfo->views[i]);
- res = (struct virgl_resource *)tinfo->views[i]->base.texture;
+ res = virgl_resource(tinfo->views[i]->base.texture);
if (res)
vws->emit_res(vws, vctx->cbuf, res->hw_res, FALSE);
}
unsigned i;
for (i = 0; i < vctx->num_vertex_buffers; i++) {
- res = (struct virgl_resource *)vctx->vertex_buffer[i].buffer;
+ res = virgl_resource(vctx->vertex_buffer[i].buffer);
if (res)
vws->emit_res(vws, vctx->cbuf, res->hw_res, FALSE);
}
struct virgl_winsys *vws = virgl_screen(vctx->base.screen)->vws;
struct virgl_resource *res;
- res = (struct virgl_resource *)vctx->index_buffer.buffer;
+ res = virgl_resource(vctx->index_buffer.buffer);
if (res)
vws->emit_res(vws, vctx->cbuf, res->hw_res, FALSE);
}
unsigned i;
for (i = 0; i < vctx->num_so_targets; i++) {
- res = (struct virgl_resource *)vctx->so_targets[i].base.buffer;
+ res = virgl_resource(vctx->so_targets[i].base.buffer);
if (res)
vws->emit_res(vws, vctx->cbuf, res->hw_res, FALSE);
}
struct virgl_resource *res;
unsigned i;
for (i = 0; i < PIPE_MAX_CONSTANT_BUFFERS; i++) {
- res = (struct virgl_resource *)vctx->ubos[shader_type][i];
+ res = virgl_resource(vctx->ubos[shader_type][i]);
if (res) {
vws->emit_res(vws, vctx->cbuf, res->hw_res, FALSE);
}
if (buf) {
if (!buf->user_buffer){
- struct virgl_resource *res = (struct virgl_resource *)buf->buffer;
+ struct virgl_resource *res = virgl_resource(buf->buffer);
virgl_encoder_set_uniform_buffer(vctx, shader, index, buf->buffer_offset,
buf->buffer_size, res);
pipe_resource_reference(&vctx->ubos[shader][index], buf->buffer);
{
struct virgl_context *vctx = virgl_context(ctx);
struct virgl_screen *vs = virgl_screen(ctx->screen);
- struct virgl_resource *grres = (struct virgl_resource *)res;
+ struct virgl_resource *grres = virgl_resource(res);
struct virgl_buffer *vbuf = virgl_buffer(res);
grres->clean = FALSE;
if (state == NULL)
return NULL;
- res = (struct virgl_resource *)texture;
+ res = virgl_resource(texture);
handle = virgl_object_assign_handle();
virgl_encode_sampler_view(vctx, handle, res, state);
const struct pipe_box *src_box)
{
struct virgl_context *vctx = virgl_context(ctx);
- struct virgl_resource *dres = (struct virgl_resource *)dst;
- struct virgl_resource *sres = (struct virgl_resource *)src;
+ struct virgl_resource *dres = virgl_resource(dst);
+ struct virgl_resource *sres = virgl_resource(src);
dres->clean = FALSE;
virgl_encode_resource_copy_region(vctx, dres,
const struct pipe_blit_info *blit)
{
struct virgl_context *vctx = virgl_context(ctx);
- struct virgl_resource *dres = (struct virgl_resource *)blit->dst.resource;
- struct virgl_resource *sres = (struct virgl_resource *)blit->src.resource;
+ struct virgl_resource *dres = virgl_resource(blit->dst.resource);
+ struct virgl_resource *sres = virgl_resource(blit->src.resource);
dres->clean = FALSE;
virgl_encode_blit(vctx, dres, sres,
int i;
virgl_encoder_write_cmd_dword(ctx, VIRGL_CMD0(VIRGL_CCMD_SET_VERTEX_BUFFERS, 0, VIRGL_SET_VERTEX_BUFFERS_SIZE(num_buffers)));
for (i = 0; i < num_buffers; i++) {
- struct virgl_resource *res = (struct virgl_resource *)buffers[i].buffer;
+ struct virgl_resource *res = virgl_resource(buffers[i].buffer);
virgl_encoder_write_dword(ctx->cbuf, buffers[i].stride);
virgl_encoder_write_dword(ctx->cbuf, buffers[i].buffer_offset);
virgl_encoder_write_res(ctx, res);
int length = VIRGL_SET_INDEX_BUFFER_SIZE(ib);
struct virgl_resource *res = NULL;
if (ib)
- res = (struct virgl_resource *)ib->buffer;
+ res = virgl_resource(ib->buffer);
virgl_encoder_write_cmd_dword(ctx, VIRGL_CMD0(VIRGL_CCMD_SET_INDEX_BUFFER, 0, length));
virgl_encoder_write_res(ctx, res);
{
struct virgl_context *vctx = virgl_context(ctx);
struct virgl_screen *vs = virgl_screen(ctx->screen);
- struct virgl_texture *vtex = (struct virgl_texture *)resource;
+ struct virgl_texture *vtex = virgl_texture(resource);
enum pipe_format format = resource->format;
struct virgl_transfer *trans;
void *ptr;
struct pipe_transfer *transfer)
{
struct virgl_context *vctx = virgl_context(ctx);
- struct virgl_transfer *trans = (struct virgl_transfer *)transfer;
- struct virgl_texture *vtex = (struct virgl_texture *)transfer->resource;
+ struct virgl_transfer *trans = virgl_transfer(transfer);
+ struct virgl_texture *vtex = virgl_texture(transfer->resource);
uint32_t l_stride;
if (transfer->resource->target != PIPE_TEXTURE_3D &&
struct winsys_handle *whandle)
{
struct virgl_screen *vs = virgl_screen(screen);
- struct virgl_texture *vtex = (struct virgl_texture *)ptex;
+ struct virgl_texture *vtex = virgl_texture(ptex);
return vs->vws->resource_get_handle(vs->vws, vtex->base.hw_res, vtex->stride[0], whandle);
}
struct pipe_resource *res)
{
struct virgl_screen *vs = virgl_screen(screen);
- struct virgl_texture *vtex = (struct virgl_texture *)res;
+ struct virgl_texture *vtex = virgl_texture(res);
vs->vws->resource_unref(vs->vws, vtex->base.hw_res);
FREE(vtex);
}