X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fgallium%2Fdrivers%2Fvc4%2Fvc4_simulator.c;h=e122c0a8668433e9b4a29375095022272036ad6d;hb=be0a994fb8689131bf6a717c1e6fa5a42c3d4657;hp=fc3d554a3ec81a84601b834c894685545c466561;hpb=0f034055f96b9dd7b1c54e8fa5422d22c26f2269;p=mesa.git diff --git a/src/gallium/drivers/vc4/vc4_simulator.c b/src/gallium/drivers/vc4/vc4_simulator.c index fc3d554a3ec..e122c0a8668 100644 --- a/src/gallium/drivers/vc4/vc4_simulator.c +++ b/src/gallium/drivers/vc4/vc4_simulator.c @@ -23,8 +23,6 @@ #ifdef USE_VC4_SIMULATOR -#include - #include "util/u_memory.h" #include "vc4_screen.h" @@ -32,6 +30,8 @@ #include "vc4_simulator_validate.h" #include "simpenrose/simpenrose.h" +#define OVERFLOW_SIZE (32 * 1024 * 1024) + static struct drm_gem_cma_object * vc4_wrap_bo_with_cma(struct drm_device *dev, struct vc4_bo *bo) { @@ -224,24 +224,24 @@ fail: } int -vc4_simulator_flush(struct vc4_context *vc4, struct drm_vc4_submit_cl *args, - struct vc4_surface *csurf) +vc4_simulator_flush(struct vc4_context *vc4, struct drm_vc4_submit_cl *args) { - struct vc4_resource *ctex = vc4_resource(csurf->base.texture); - uint32_t winsys_stride = ctex->bo->simulator_winsys_stride; - uint32_t sim_stride = ctex->slices[0].stride; + struct vc4_surface *csurf = vc4_surface(vc4->framebuffer.cbufs[0]); + struct vc4_resource *ctex = csurf ? vc4_resource(csurf->base.texture) : NULL; + uint32_t winsys_stride = ctex ? ctex->bo->simulator_winsys_stride : 0; + uint32_t sim_stride = ctex ? ctex->slices[0].stride : 0; uint32_t row_len = MIN2(sim_stride, winsys_stride); struct exec_info exec; struct drm_device local_dev = { .vc4 = vc4, - .simulator_mem_next = 0, + .simulator_mem_next = OVERFLOW_SIZE, }; struct drm_device *dev = &local_dev; int ret; memset(&exec, 0, sizeof(exec)); - if (ctex->bo->simulator_winsys_map) { + if (ctex && ctex->bo->simulator_winsys_map) { #if 0 fprintf(stderr, "%dx%d %d %d %d\n", ctex->base.b.width0, ctex->base.b.height0, @@ -276,7 +276,7 @@ vc4_simulator_flush(struct vc4_context *vc4, struct drm_vc4_submit_cl *args, free(exec.exec_bo); - if (ctex->bo->simulator_winsys_map) { + if (ctex && ctex->bo->simulator_winsys_map) { for (int y = 0; y < ctex->base.b.height0; y++) { memcpy(ctex->bo->simulator_winsys_map + y * winsys_stride, ctex->bo->map + y * sim_stride, @@ -290,9 +290,23 @@ vc4_simulator_flush(struct vc4_context *vc4, struct drm_vc4_submit_cl *args, void vc4_simulator_init(struct vc4_screen *screen) { - simpenrose_init_hardware(); - screen->simulator_mem_base = simpenrose_get_mem_start(); - screen->simulator_mem_size = simpenrose_get_mem_size(); + screen->simulator_mem_size = 256 * 1024 * 1024; + screen->simulator_mem_base = malloc(screen->simulator_mem_size); + + /* We supply our own memory so that we can have more aperture + * available (256MB instead of simpenrose's default 64MB). + */ + simpenrose_init_hardware_supply_mem(screen->simulator_mem_base, + screen->simulator_mem_size); + + /* Carve out low memory for tile allocation overflow. The kernel + * should be automatically handling overflow memory setup on real + * hardware, but for simulation we just get one shot to set up enough + * overflow memory before execution. This overflow mem will be used + * up over the whole lifetime of simpenrose (not reused on each + * flush), so it had better be big. + */ + simpenrose_supply_overflow_mem(0, OVERFLOW_SIZE); } #endif /* USE_VC4_SIMULATOR */