freedreno/ir3: add ctx->mem_to_mem()
[mesa.git] / src / gallium / drivers / virgl / virgl_texture.c
index 1838fdf47987b84781593eb2fae5c7cd9f3c9387..150a5ebd8c7195a33c12bdbc042422f3069c998e 100644 (file)
  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  * USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
-#include "util/u_memory.h"
 #include "util/u_format.h"
-#include "virgl_screen.h"
-#include "virgl_resource.h"
+#include "util/u_inlines.h"
+#include "util/u_memory.h"
+
 #include "virgl_context.h"
+#include "virgl_resource.h"
+#include "virgl_screen.h"
 
 static void virgl_copy_region_with_blit(struct pipe_context *pipe,
                                         struct pipe_resource *dst,
@@ -126,7 +128,7 @@ static void *virgl_texture_transfer_map(struct pipe_context *ctx,
 {
    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;
@@ -143,8 +145,8 @@ static void *virgl_texture_transfer_map(struct pipe_context *ctx,
    if (doflushwait)
       ctx->flush(ctx, NULL, 0);
 
-   trans = util_slab_alloc(&vctx->texture_transfer_pool);
-   if (trans == NULL)
+   trans = slab_alloc(&vctx->texture_transfer_pool);
+   if (!trans)
       return NULL;
 
    trans->base.resource = resource;
@@ -206,8 +208,8 @@ static void virgl_texture_transfer_unmap(struct pipe_context *ctx,
                                          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 &&
@@ -233,7 +235,7 @@ static void virgl_texture_transfer_unmap(struct pipe_context *ctx,
    if (trans->resolve_tmp)
       pipe_resource_reference((struct pipe_resource **)&trans->resolve_tmp, NULL);
 
-   util_slab_free(&vctx->texture_transfer_pool, trans);
+   slab_free(&vctx->texture_transfer_pool, trans);
 }
 
 
@@ -281,7 +283,7 @@ static boolean virgl_texture_get_handle(struct pipe_screen *screen,
                                          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);
 }
@@ -290,7 +292,7 @@ static void virgl_texture_destroy(struct pipe_screen *screen,
                                   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);
 }
@@ -302,7 +304,6 @@ static const struct u_resource_vtbl virgl_texture_vtbl =
    virgl_texture_transfer_map,          /* transfer_map */
    NULL,                                /* transfer_flush_region */
    virgl_texture_transfer_unmap,        /* transfer_unmap */
-   NULL                                 /* transfer_inline_write */
 };
 
 struct pipe_resource *