bool brw_gs_precompile(struct gl_context *ctx, struct gl_shader_program *shader_prog, struct gl_program *prog) { struct brw_context *brw = brw_context(ctx); struct brw_gs_prog_key key; uint32_t old_prog_offset = brw->gs.base.prog_offset; struct brw_gs_prog_data *old_prog_data = brw->gs.prog_data; bool success; struct gl_geometry_program *gp = (struct gl_geometry_program *) prog; struct brw_geometry_program *bgp = brw_geometry_program(gp); memset(&key, 0, sizeof(key)); brw_vue_setup_prog_key_for_precompile(ctx, &key.base, bgp->id, &gp->Base); /* Assume that the set of varyings coming in from the vertex shader exactly * matches what the geometry shader requires. */ key.input_varyings = gp->Base.InputsRead; success = brw_codegen_gs_prog(brw, shader_prog, bgp, &key); brw->gs.base.prog_offset = old_prog_offset; brw->gs.prog_data = old_prog_data; return success; }
bool brw_gs_precompile(struct gl_context *ctx, struct gl_shader_program *shader_prog, struct gl_program *prog) { struct brw_context *brw = brw_context(ctx); struct brw_gs_prog_key key; uint32_t old_prog_offset = brw->gs.base.prog_offset; struct brw_gs_prog_data *old_prog_data = brw->gs.prog_data; bool success; struct gl_geometry_program *gp = (struct gl_geometry_program *) prog; struct brw_geometry_program *bgp = brw_geometry_program(gp); memset(&key, 0, sizeof(key)); brw_setup_tex_for_precompile(brw, &key.tex, prog); key.program_string_id = bgp->id; success = brw_codegen_gs_prog(brw, shader_prog, bgp, &key); brw->gs.base.prog_offset = old_prog_offset; brw->gs.prog_data = old_prog_data; return success; }
void brw_upload_gs_prog(struct brw_context *brw) { struct gl_context *ctx = &brw->ctx; struct gl_shader_program **current = ctx->_Shader->CurrentProgram; struct brw_stage_state *stage_state = &brw->gs.base; struct brw_gs_prog_key key; /* BRW_NEW_GEOMETRY_PROGRAM */ struct brw_geometry_program *gp = (struct brw_geometry_program *) brw->geometry_program; if (!brw_gs_state_dirty(brw)) return; if (gp == NULL) { /* No geometry shader. Vertex data just passes straight through. */ if (brw->ctx.NewDriverState & BRW_NEW_VUE_MAP_VS) { brw->vue_map_geom_out = brw->vue_map_vs; brw->ctx.NewDriverState |= BRW_NEW_VUE_MAP_GEOM_OUT; } if (brw->gen == 6 && (brw->ctx.NewDriverState & BRW_NEW_TRANSFORM_FEEDBACK)) { gen6_brw_upload_ff_gs_prog(brw); return; } /* Other state atoms had better not try to access prog_data, since * there's no GS program. */ brw->gs.prog_data = NULL; brw->gs.base.prog_data = NULL; return; } brw_gs_populate_key(brw, &key); if (!brw_search_cache(&brw->cache, BRW_CACHE_GS_PROG, &key, sizeof(key), &stage_state->prog_offset, &brw->gs.prog_data)) { bool success = brw_codegen_gs_prog(brw, current[MESA_SHADER_GEOMETRY], gp, &key); assert(success); (void)success; } brw->gs.base.prog_data = &brw->gs.prog_data->base.base; if (memcmp(&brw->gs.prog_data->base.vue_map, &brw->vue_map_geom_out, sizeof(brw->vue_map_geom_out)) != 0) { brw->vue_map_geom_out = brw->gs.prog_data->base.vue_map; brw->ctx.NewDriverState |= BRW_NEW_VUE_MAP_GEOM_OUT; } }
void brw_upload_gs_prog(struct brw_context *brw) { struct brw_stage_state *stage_state = &brw->gs.base; struct brw_gs_prog_key key; /* BRW_NEW_GEOMETRY_PROGRAM */ struct brw_program *gp = (struct brw_program *) brw->geometry_program; if (!brw_gs_state_dirty(brw)) return; if (gp == NULL) { /* No geometry shader. Vertex data just passes straight through. */ if (brw->gen == 6 && (brw->ctx.NewDriverState & BRW_NEW_TRANSFORM_FEEDBACK)) { gen6_brw_upload_ff_gs_prog(brw); return; } /* Other state atoms had better not try to access prog_data, since * there's no GS program. */ brw->gs.base.prog_data = NULL; return; } brw_gs_populate_key(brw, &key); if (!brw_search_cache(&brw->cache, BRW_CACHE_GS_PROG, &key, sizeof(key), &stage_state->prog_offset, &brw->gs.base.prog_data)) { bool success = brw_codegen_gs_prog(brw, gp, &key); assert(success); (void)success; } }