radeonsi: don't crash if input_usage_mask is 0 for a VS input
[mesa.git] / src / gallium / drivers / lima / lima_texture.c
index 6a8fa128582e15d6971c1e9e28a8925f7bdefa66..0258aa23ec9d76bed857e86f930798237e6f6dcb 100644 (file)
@@ -34,7 +34,7 @@
 #include "lima_screen.h"
 #include "lima_texture.h"
 #include "lima_resource.h"
-#include "lima_submit.h"
+#include "lima_job.h"
 #include "lima_util.h"
 #include "lima_format.h"
 
@@ -63,6 +63,10 @@ lima_texture_desc_set_va(lima_tex_desc *desc,
    desc->va[va_idx + 1] |= va >> (32 - va_bit_idx);
 }
 
+/*
+ * Note: this function is used by both draw and flush code path,
+ * make sure no lima_job_get() is called inside this.
+ */
 void
 lima_texture_desc_set_res(struct lima_context *ctx, lima_tex_desc *desc,
                           struct pipe_resource *prsc,
@@ -79,7 +83,7 @@ lima_texture_desc_set_res(struct lima_context *ctx, lima_tex_desc *desc,
    }
 
    desc->format = lima_format_get_texel(prsc->format);
-   desc->swap_r_b = lima_format_get_swap_rb(prsc->format);
+   desc->swap_r_b = lima_format_get_texel_swap_rb(prsc->format);
    desc->width  = width;
    desc->height = height;
    desc->unknown_3_1 = 1;
@@ -253,6 +257,7 @@ lima_calc_tex_desc_size(struct lima_sampler_view *texture)
 void
 lima_update_textures(struct lima_context *ctx)
 {
+   struct lima_job *job = lima_job_get(ctx);
    struct lima_texture_stateobj *lima_tex = &ctx->tex_stateobj;
 
    assert (lima_tex->num_samplers <= 16);
@@ -261,11 +266,12 @@ lima_update_textures(struct lima_context *ctx)
    if (!lima_tex->num_samplers || !lima_tex->num_textures)
       return;
 
-   /* we always need to add texture bo to submit */
+   /* we always need to add texture bo to job */
    for (int i = 0; i < lima_tex->num_samplers; i++) {
       struct lima_sampler_view *texture = lima_sampler_view(lima_tex->textures[i]);
       struct lima_resource *rsc = lima_resource(texture->base.texture);
-      lima_submit_add_bo(ctx->submit, LIMA_PIPE_PP, rsc->bo, LIMA_SUBMIT_BO_READ);
+      lima_flush_previous_job_writing_resource(ctx, texture->base.texture);
+      lima_job_add_bo(job, LIMA_PIPE_PP, rsc->bo, LIMA_SUBMIT_BO_READ);
    }
 
    /* do not regenerate texture desc if no change */
@@ -293,11 +299,11 @@ lima_update_textures(struct lima_context *ctx)
    }
 
    lima_dump_command_stream_print(
-      descs, size, false, "add textures_desc at va %x\n",
+      job->dump, descs, size, false, "add textures_desc at va %x\n",
       lima_ctx_buff_va(ctx, lima_ctx_buff_pp_tex_desc));
 
    lima_dump_texture_descriptor(
-      descs, size,
+      job->dump, descs, size,
       lima_ctx_buff_va(ctx, lima_ctx_buff_pp_tex_desc) + lima_tex_list_size,
       lima_tex_list_size);
 }