#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include "pan_bo.h"
#include "pan_context.h"
+#include "pan_util.h"
#include "compiler/nir/nir.h"
#include "nir/tgsi_to_nir.h"
struct mali_shader_meta *meta,
enum pipe_shader_ir ir_type,
const void *ir,
- const char *src,
gl_shader_stage stage,
- struct panfrost_shader_state *state)
+ struct panfrost_shader_state *state,
+ uint64_t *outputs_written)
{
+ struct panfrost_screen *screen = pan_screen(ctx->base.screen);
uint8_t *dst;
nir_shader *s;
s->info.stage = stage;
- if (stage == MESA_SHADER_FRAGMENT) {
- /* Inject the alpha test now if we need to */
-
- if (state->alpha_state.enabled) {
- NIR_PASS_V(s, nir_lower_alpha_test, state->alpha_state.func, false);
- }
- }
-
/* Call out to Midgard compiler given the above NIR */
midgard_program program = {
.alpha_ref = state->alpha_state.ref_value
};
- midgard_compile_shader_nir(&ctx->compiler, s, &program, false);
+ midgard_compile_shader_nir(s, &program, false, 0, screen->gpu_id,
+ pan_debug & PAN_DBG_PRECOMPILE);
/* Prepare the compiled binary for upload */
int size = program.compiled.size;
* I bet someone just thought that would be a cute pun. At least,
* that's how I'd do it. */
- meta->shader = panfrost_upload(&ctx->shaders, dst, size) | program.first_tag;
+ state->bo = panfrost_bo_create(screen, size, PAN_BO_EXECUTE);
+ memcpy(state->bo->cpu, dst, size);
+ meta->shader = state->bo->gpu | program.first_tag;
util_dynarray_fini(&program.compiled);
state->writes_point_size = program.writes_point_size;
state->reads_point_coord = false;
state->helper_invocations = s->info.fs.needs_helper_invocations;
+ state->stack_size = program.tls_size;
+
+ if (outputs_written)
+ *outputs_written = s->info.outputs_written;
/* Separate as primary uniform count is truncated */
state->uniform_count = program.uniform_count;
/* Check for special cases, otherwise assume general varying */
if (location == VARYING_SLOT_POS) {
- v.index = 1;
- v.format = MALI_VARYING_POS;
+ if (stage == MESA_SHADER_FRAGMENT)
+ state->reads_frag_coord = true;
+ else
+ v.format = MALI_VARYING_POS;
} else if (location == VARYING_SLOT_PSIZ) {
- v.index = 2;
v.format = MALI_R16F;
v.swizzle = default_vec1_swizzle;
state->writes_point_size = true;
} else if (location == VARYING_SLOT_PNTC) {
- v.index = 3;
v.format = MALI_RG16F;
v.swizzle = default_vec2_swizzle;
state->reads_point_coord = true;
} else if (location == VARYING_SLOT_FACE) {
- v.index = 4;
v.format = MALI_R32I;
v.swizzle = default_vec1_swizzle;
state->reads_face = true;
- } else {
- v.index = 0;
}
state->varyings[i] = v;