mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 05:18:08 +02:00
freedreno/ir3: bit of shader API refactoring
Since for transform-feedback, we'll need more than just the TGSI tokens from the state object, just pass the entire state object to ir3_shader_create(). This also cleans things up a bit for some day in the future when we could take shader either as TGSI or directly NIR (for ex, glsl2nir or spirv2nir paths). In the same spirit, drop extra args from ir3_compile_shader_nir() (since it can anyways get what it needs from the ir3_shader_variant). Signed-off-by: Rob Clark <robclark@freedesktop.org>
This commit is contained in:
parent
bc5e2bec30
commit
0815729d96
7 changed files with 25 additions and 22 deletions
|
|
@ -51,7 +51,7 @@ create_shader_stateobj(struct pipe_context *pctx, const struct pipe_shader_state
|
|||
enum shader_t type)
|
||||
{
|
||||
struct fd3_shader_stateobj *so = CALLOC_STRUCT(fd3_shader_stateobj);
|
||||
so->shader = ir3_shader_create(pctx, cso->tokens, type);
|
||||
so->shader = ir3_shader_create(pctx, cso, type);
|
||||
return so;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ create_shader_stateobj(struct pipe_context *pctx, const struct pipe_shader_state
|
|||
enum shader_t type)
|
||||
{
|
||||
struct fd4_shader_stateobj *so = CALLOC_STRUCT(fd4_shader_stateobj);
|
||||
so->shader = ir3_shader_create(pctx, cso->tokens, type);
|
||||
so->shader = ir3_shader_create(pctx, cso, type);
|
||||
return so;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -181,10 +181,6 @@ int main(int argc, char **argv)
|
|||
|
||||
filename = argv[n];
|
||||
|
||||
memset(&v, 0, sizeof(v));
|
||||
v.key = key;
|
||||
v.shader = &s;
|
||||
|
||||
ret = read_file(filename, &ptr, &size);
|
||||
if (ret) {
|
||||
print_usage();
|
||||
|
|
@ -197,6 +193,13 @@ int main(int argc, char **argv)
|
|||
if (!tgsi_text_translate(ptr, toks, Elements(toks)))
|
||||
errx(1, "could not parse `%s'", filename);
|
||||
|
||||
memset(&s, 0, sizeof(s));
|
||||
s.tokens = toks;
|
||||
|
||||
memset(&v, 0, sizeof(v));
|
||||
v.key = key;
|
||||
v.shader = &s;
|
||||
|
||||
tgsi_parse_init(&parse, toks);
|
||||
switch (parse.FullHeader.Processor.Processor) {
|
||||
case TGSI_PROCESSOR_FRAGMENT:
|
||||
|
|
@ -214,7 +217,7 @@ int main(int argc, char **argv)
|
|||
compiler = ir3_compiler_create(320);
|
||||
|
||||
info = "NIR compiler";
|
||||
ret = ir3_compile_shader_nir(compiler, &v, toks, key);
|
||||
ret = ir3_compile_shader_nir(compiler, &v);
|
||||
if (ret) {
|
||||
fprintf(stderr, "compiler failed!\n");
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -43,8 +43,6 @@ struct ir3_compiler * ir3_compiler_create(uint32_t gpu_id);
|
|||
void ir3_compiler_destroy(struct ir3_compiler *compiler);
|
||||
|
||||
int ir3_compile_shader_nir(struct ir3_compiler *compiler,
|
||||
struct ir3_shader_variant *so,
|
||||
const struct tgsi_token *tokens,
|
||||
struct ir3_shader_key key);
|
||||
struct ir3_shader_variant *so);
|
||||
|
||||
#endif /* IR3_COMPILER_H_ */
|
||||
|
|
|
|||
|
|
@ -2283,9 +2283,7 @@ fixup_frag_inputs(struct ir3_compile *ctx)
|
|||
|
||||
int
|
||||
ir3_compile_shader_nir(struct ir3_compiler *compiler,
|
||||
struct ir3_shader_variant *so,
|
||||
const struct tgsi_token *tokens,
|
||||
struct ir3_shader_key key)
|
||||
struct ir3_shader_variant *so)
|
||||
{
|
||||
struct ir3_compile *ctx;
|
||||
struct ir3 *ir;
|
||||
|
|
@ -2295,7 +2293,7 @@ ir3_compile_shader_nir(struct ir3_compiler *compiler,
|
|||
|
||||
assert(!so->ir);
|
||||
|
||||
ctx = compile_init(compiler, so, tokens);
|
||||
ctx = compile_init(compiler, so, so->shader->tokens);
|
||||
if (!ctx) {
|
||||
DBG("INIT failed!");
|
||||
ret = -1;
|
||||
|
|
@ -2320,7 +2318,7 @@ ir3_compile_shader_nir(struct ir3_compiler *compiler,
|
|||
fixup_frag_inputs(ctx);
|
||||
|
||||
/* at this point, for binning pass, throw away unneeded outputs: */
|
||||
if (key.binning_pass) {
|
||||
if (so->key.binning_pass) {
|
||||
for (i = 0, j = 0; i < so->outputs_count; i++) {
|
||||
unsigned name = sem2name(so->outputs[i].semantic);
|
||||
unsigned idx = sem2idx(so->outputs[i].semantic);
|
||||
|
|
@ -2345,7 +2343,7 @@ ir3_compile_shader_nir(struct ir3_compiler *compiler,
|
|||
/* if we want half-precision outputs, mark the output registers
|
||||
* as half:
|
||||
*/
|
||||
if (key.half_precision) {
|
||||
if (so->key.half_precision) {
|
||||
for (i = 0; i < ir->noutputs; i++) {
|
||||
struct ir3_instruction *out = ir->outputs[i];
|
||||
if (!out)
|
||||
|
|
|
|||
|
|
@ -177,7 +177,6 @@ static struct ir3_shader_variant *
|
|||
create_variant(struct ir3_shader *shader, struct ir3_shader_key key)
|
||||
{
|
||||
struct ir3_shader_variant *v = CALLOC_STRUCT(ir3_shader_variant);
|
||||
const struct tgsi_token *tokens = shader->tokens;
|
||||
int ret;
|
||||
|
||||
if (!v)
|
||||
|
|
@ -191,10 +190,10 @@ create_variant(struct ir3_shader *shader, struct ir3_shader_key key)
|
|||
if (fd_mesa_debug & FD_DBG_DISASM) {
|
||||
DBG("dump tgsi: type=%d, k={bp=%u,cts=%u,hp=%u}", shader->type,
|
||||
key.binning_pass, key.color_two_side, key.half_precision);
|
||||
tgsi_dump(tokens, 0);
|
||||
tgsi_dump(shader->tokens, 0);
|
||||
}
|
||||
|
||||
ret = ir3_compile_shader_nir(shader->compiler, v, tokens, key);
|
||||
ret = ir3_compile_shader_nir(shader->compiler, v);
|
||||
if (ret) {
|
||||
debug_error("compile failed!");
|
||||
goto fail;
|
||||
|
|
@ -273,7 +272,8 @@ ir3_shader_destroy(struct ir3_shader *shader)
|
|||
}
|
||||
|
||||
struct ir3_shader *
|
||||
ir3_shader_create(struct pipe_context *pctx, const struct tgsi_token *tokens,
|
||||
ir3_shader_create(struct pipe_context *pctx,
|
||||
const struct pipe_shader_state *cso,
|
||||
enum shader_t type)
|
||||
{
|
||||
struct ir3_shader *shader = CALLOC_STRUCT(ir3_shader);
|
||||
|
|
@ -281,7 +281,8 @@ ir3_shader_create(struct pipe_context *pctx, const struct tgsi_token *tokens,
|
|||
shader->id = ++shader->compiler->shader_count;
|
||||
shader->pctx = pctx;
|
||||
shader->type = type;
|
||||
shader->tokens = tgsi_dup_tokens(tokens);
|
||||
shader->tokens = tgsi_dup_tokens(cso->tokens);
|
||||
shader->stream_output = cso->stream_output;
|
||||
if (fd_mesa_debug & FD_DBG_SHADERDB) {
|
||||
/* if shader-db run, create a standard variant immediately
|
||||
* (as otherwise nothing will trigger the shader to be
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@
|
|||
#ifndef IR3_SHADER_H_
|
||||
#define IR3_SHADER_H_
|
||||
|
||||
#include "pipe/p_state.h"
|
||||
|
||||
#include "ir3.h"
|
||||
#include "disasm.h"
|
||||
|
||||
|
|
@ -203,6 +205,7 @@ struct ir3_shader {
|
|||
|
||||
struct pipe_context *pctx;
|
||||
const struct tgsi_token *tokens;
|
||||
struct pipe_stream_output_info stream_output;
|
||||
|
||||
struct ir3_shader_variant *variants;
|
||||
|
||||
|
|
@ -215,7 +218,7 @@ struct ir3_shader {
|
|||
void * ir3_shader_assemble(struct ir3_shader_variant *v, uint32_t gpu_id);
|
||||
|
||||
struct ir3_shader * ir3_shader_create(struct pipe_context *pctx,
|
||||
const struct tgsi_token *tokens, enum shader_t type);
|
||||
const struct pipe_shader_state *cso, enum shader_t type);
|
||||
void ir3_shader_destroy(struct ir3_shader *shader);
|
||||
struct ir3_shader_variant * ir3_shader_variant(struct ir3_shader *shader,
|
||||
struct ir3_shader_key key);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue