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;
}
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;
}
filename = argv[n];
- memset(&v, 0, sizeof(v));
- v.key = key;
- v.shader = &s;
-
ret = read_file(filename, &ptr, &size);
if (ret) {
print_usage();
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:
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;
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_ */
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;
assert(!so->ir);
- ctx = compile_init(compiler, so, tokens);
+ ctx = compile_init(compiler, so, so->shader->tokens);
if (!ctx) {
DBG("INIT failed!");
ret = -1;
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);
/* 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)
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)
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;
}
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);
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
#ifndef IR3_SHADER_H_
#define IR3_SHADER_H_
+#include "pipe/p_state.h"
+
#include "ir3.h"
#include "disasm.h"
struct pipe_context *pctx;
const struct tgsi_token *tokens;
+ struct pipe_stream_output_info stream_output;
struct ir3_shader_variant *variants;
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);