freedreno: Plumb pipe_screen through to irX_tgsi_to_nir.
This patch makes it possible for freedreno to pass a pipe_screen to tgsi_to_nir. This will be needed when tgsi_to_nir supports reading pipe capabilities. Signed-off-by: Timur Kristóf <timur.kristof@gmail.com> Tested-by: Rob Clark <robdclark@gmail.com> Reviewed-by: Rob Clark <robdclark@gmail.com>
This commit is contained in:

committed by
Eric Anholt

parent
6684e039eb
commit
e582e761b7
@@ -102,7 +102,7 @@ fd2_fp_state_create(struct pipe_context *pctx,
|
|||||||
(nir_lower_io_options)0);
|
(nir_lower_io_options)0);
|
||||||
} else {
|
} else {
|
||||||
assert(cso->type == PIPE_SHADER_IR_TGSI);
|
assert(cso->type == PIPE_SHADER_IR_TGSI);
|
||||||
so->nir = ir2_tgsi_to_nir(cso->tokens);
|
so->nir = ir2_tgsi_to_nir(cso->tokens, pctx->screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ir2_optimize_nir(so->nir, true))
|
if (ir2_optimize_nir(so->nir, true))
|
||||||
@@ -142,7 +142,7 @@ fd2_vp_state_create(struct pipe_context *pctx,
|
|||||||
(nir_lower_io_options)0);
|
(nir_lower_io_options)0);
|
||||||
} else {
|
} else {
|
||||||
assert(cso->type == PIPE_SHADER_IR_TGSI);
|
assert(cso->type == PIPE_SHADER_IR_TGSI);
|
||||||
so->nir = ir2_tgsi_to_nir(cso->tokens);
|
so->nir = ir2_tgsi_to_nir(cso->tokens, pctx->screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ir2_optimize_nir(so->nir, true))
|
if (ir2_optimize_nir(so->nir, true))
|
||||||
|
@@ -28,6 +28,7 @@
|
|||||||
#define IR2_H_
|
#define IR2_H_
|
||||||
|
|
||||||
#include "compiler/nir/nir.h"
|
#include "compiler/nir/nir.h"
|
||||||
|
#include "pipe/p_context.h"
|
||||||
|
|
||||||
struct ir2_fetch_info {
|
struct ir2_fetch_info {
|
||||||
/* dword offset of the fetch instruction */
|
/* dword offset of the fetch instruction */
|
||||||
@@ -85,7 +86,8 @@ struct tgsi_token;
|
|||||||
void ir2_compile(struct fd2_shader_stateobj *so, unsigned variant,
|
void ir2_compile(struct fd2_shader_stateobj *so, unsigned variant,
|
||||||
struct fd2_shader_stateobj *fp);
|
struct fd2_shader_stateobj *fp);
|
||||||
|
|
||||||
struct nir_shader *ir2_tgsi_to_nir(const struct tgsi_token *tokens);
|
struct nir_shader *ir2_tgsi_to_nir(const struct tgsi_token *tokens,
|
||||||
|
struct pipe_screen *screen);
|
||||||
|
|
||||||
const nir_shader_compiler_options *ir2_get_compiler_options(void);
|
const nir_shader_compiler_options *ir2_get_compiler_options(void);
|
||||||
|
|
||||||
|
@@ -43,8 +43,11 @@ static const nir_shader_compiler_options options = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct nir_shader *
|
struct nir_shader *
|
||||||
ir2_tgsi_to_nir(const struct tgsi_token *tokens)
|
ir2_tgsi_to_nir(const struct tgsi_token *tokens,
|
||||||
|
struct pipe_screen *screen)
|
||||||
{
|
{
|
||||||
|
/* TODO: pass screen to tgsi_to_nir when it needs that. */
|
||||||
|
(void) screen;
|
||||||
return tgsi_to_nir(tokens, &options);
|
return tgsi_to_nir(tokens, &options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -44,7 +44,7 @@ create_shader_stateobj(struct pipe_context *pctx, const struct pipe_shader_state
|
|||||||
{
|
{
|
||||||
struct fd_context *ctx = fd_context(pctx);
|
struct fd_context *ctx = fd_context(pctx);
|
||||||
struct ir3_compiler *compiler = ctx->screen->compiler;
|
struct ir3_compiler *compiler = ctx->screen->compiler;
|
||||||
return ir3_shader_create(compiler, cso, type, &ctx->debug);
|
return ir3_shader_create(compiler, cso, type, &ctx->debug, pctx->screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
|
@@ -43,7 +43,7 @@ create_shader_stateobj(struct pipe_context *pctx, const struct pipe_shader_state
|
|||||||
{
|
{
|
||||||
struct fd_context *ctx = fd_context(pctx);
|
struct fd_context *ctx = fd_context(pctx);
|
||||||
struct ir3_compiler *compiler = ctx->screen->compiler;
|
struct ir3_compiler *compiler = ctx->screen->compiler;
|
||||||
return ir3_shader_create(compiler, cso, type, &ctx->debug);
|
return ir3_shader_create(compiler, cso, type, &ctx->debug, pctx->screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
|
@@ -56,7 +56,7 @@ fd5_create_compute_state(struct pipe_context *pctx,
|
|||||||
|
|
||||||
struct ir3_compiler *compiler = ctx->screen->compiler;
|
struct ir3_compiler *compiler = ctx->screen->compiler;
|
||||||
struct fd5_compute_stateobj *so = CALLOC_STRUCT(fd5_compute_stateobj);
|
struct fd5_compute_stateobj *so = CALLOC_STRUCT(fd5_compute_stateobj);
|
||||||
so->shader = ir3_shader_create_compute(compiler, cso, &ctx->debug);
|
so->shader = ir3_shader_create_compute(compiler, cso, &ctx->debug, pctx->screen);
|
||||||
return so;
|
return so;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -46,7 +46,7 @@ create_shader_stateobj(struct pipe_context *pctx, const struct pipe_shader_state
|
|||||||
{
|
{
|
||||||
struct fd_context *ctx = fd_context(pctx);
|
struct fd_context *ctx = fd_context(pctx);
|
||||||
struct ir3_compiler *compiler = ctx->screen->compiler;
|
struct ir3_compiler *compiler = ctx->screen->compiler;
|
||||||
return ir3_shader_create(compiler, cso, type, &ctx->debug);
|
return ir3_shader_create(compiler, cso, type, &ctx->debug, pctx->screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
|
@@ -56,7 +56,7 @@ fd6_create_compute_state(struct pipe_context *pctx,
|
|||||||
|
|
||||||
struct ir3_compiler *compiler = ctx->screen->compiler;
|
struct ir3_compiler *compiler = ctx->screen->compiler;
|
||||||
struct fd6_compute_stateobj *so = CALLOC_STRUCT(fd6_compute_stateobj);
|
struct fd6_compute_stateobj *so = CALLOC_STRUCT(fd6_compute_stateobj);
|
||||||
so->shader = ir3_shader_create_compute(compiler, cso, &ctx->debug);
|
so->shader = ir3_shader_create_compute(compiler, cso, &ctx->debug, pctx->screen);
|
||||||
return so;
|
return so;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -45,7 +45,7 @@ create_shader_stateobj(struct pipe_context *pctx, const struct pipe_shader_state
|
|||||||
{
|
{
|
||||||
struct fd_context *ctx = fd_context(pctx);
|
struct fd_context *ctx = fd_context(pctx);
|
||||||
struct ir3_compiler *compiler = ctx->screen->compiler;
|
struct ir3_compiler *compiler = ctx->screen->compiler;
|
||||||
return ir3_shader_create(compiler, cso, type, &ctx->debug);
|
return ir3_shader_create(compiler, cso, type, &ctx->debug, pctx->screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
|
@@ -49,6 +49,8 @@
|
|||||||
#include "compiler/nir_types.h"
|
#include "compiler/nir_types.h"
|
||||||
#include "compiler/spirv/nir_spirv.h"
|
#include "compiler/spirv/nir_spirv.h"
|
||||||
|
|
||||||
|
#include "pipe/p_context.h"
|
||||||
|
|
||||||
static void dump_info(struct ir3_shader_variant *so, const char *str)
|
static void dump_info(struct ir3_shader_variant *so, const char *str)
|
||||||
{
|
{
|
||||||
uint32_t *bin;
|
uint32_t *bin;
|
||||||
@@ -462,7 +464,7 @@ int main(int argc, char **argv)
|
|||||||
if (ir3_shader_debug & IR3_DBG_OPTMSGS)
|
if (ir3_shader_debug & IR3_DBG_OPTMSGS)
|
||||||
tgsi_dump(toks, 0);
|
tgsi_dump(toks, 0);
|
||||||
|
|
||||||
nir = ir3_tgsi_to_nir(compiler, toks);
|
nir = ir3_tgsi_to_nir(compiler, toks, NULL);
|
||||||
NIR_PASS_V(nir, nir_lower_global_vars_to_local);
|
NIR_PASS_V(nir, nir_lower_global_vars_to_local);
|
||||||
} else if (from_spirv) {
|
} else if (from_spirv) {
|
||||||
nir = load_spirv(filenames[0], entry, stage);
|
nir = load_spirv(filenames[0], entry, stage);
|
||||||
|
@@ -25,6 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "pipe/p_state.h"
|
#include "pipe/p_state.h"
|
||||||
|
#include "pipe/p_screen.h"
|
||||||
#include "util/u_string.h"
|
#include "util/u_string.h"
|
||||||
#include "util/u_memory.h"
|
#include "util/u_memory.h"
|
||||||
#include "util/u_inlines.h"
|
#include "util/u_inlines.h"
|
||||||
@@ -120,7 +121,8 @@ copy_stream_out(struct ir3_stream_output_info *i,
|
|||||||
struct ir3_shader *
|
struct ir3_shader *
|
||||||
ir3_shader_create(struct ir3_compiler *compiler,
|
ir3_shader_create(struct ir3_compiler *compiler,
|
||||||
const struct pipe_shader_state *cso, gl_shader_stage type,
|
const struct pipe_shader_state *cso, gl_shader_stage type,
|
||||||
struct pipe_debug_callback *debug)
|
struct pipe_debug_callback *debug,
|
||||||
|
struct pipe_screen *screen)
|
||||||
{
|
{
|
||||||
nir_shader *nir;
|
nir_shader *nir;
|
||||||
if (cso->type == PIPE_SHADER_IR_NIR) {
|
if (cso->type == PIPE_SHADER_IR_NIR) {
|
||||||
@@ -131,7 +133,7 @@ ir3_shader_create(struct ir3_compiler *compiler,
|
|||||||
if (ir3_shader_debug & IR3_DBG_DISASM) {
|
if (ir3_shader_debug & IR3_DBG_DISASM) {
|
||||||
tgsi_dump(cso->tokens, 0);
|
tgsi_dump(cso->tokens, 0);
|
||||||
}
|
}
|
||||||
nir = ir3_tgsi_to_nir(compiler, cso->tokens);
|
nir = ir3_tgsi_to_nir(compiler, cso->tokens, screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ir3_shader *shader = ir3_shader_from_nir(compiler, nir);
|
struct ir3_shader *shader = ir3_shader_from_nir(compiler, nir);
|
||||||
@@ -156,7 +158,8 @@ ir3_shader_create(struct ir3_compiler *compiler,
|
|||||||
struct ir3_shader *
|
struct ir3_shader *
|
||||||
ir3_shader_create_compute(struct ir3_compiler *compiler,
|
ir3_shader_create_compute(struct ir3_compiler *compiler,
|
||||||
const struct pipe_compute_state *cso,
|
const struct pipe_compute_state *cso,
|
||||||
struct pipe_debug_callback *debug)
|
struct pipe_debug_callback *debug,
|
||||||
|
struct pipe_screen *screen)
|
||||||
{
|
{
|
||||||
nir_shader *nir;
|
nir_shader *nir;
|
||||||
if (cso->ir_type == PIPE_SHADER_IR_NIR) {
|
if (cso->ir_type == PIPE_SHADER_IR_NIR) {
|
||||||
@@ -167,7 +170,7 @@ ir3_shader_create_compute(struct ir3_compiler *compiler,
|
|||||||
if (ir3_shader_debug & IR3_DBG_DISASM) {
|
if (ir3_shader_debug & IR3_DBG_DISASM) {
|
||||||
tgsi_dump(cso->prog, 0);
|
tgsi_dump(cso->prog, 0);
|
||||||
}
|
}
|
||||||
nir = ir3_tgsi_to_nir(compiler, cso->prog);
|
nir = ir3_tgsi_to_nir(compiler, cso->prog, screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ir3_shader *shader = ir3_shader_from_nir(compiler, nir);
|
struct ir3_shader *shader = ir3_shader_from_nir(compiler, nir);
|
||||||
@@ -176,8 +179,12 @@ ir3_shader_create_compute(struct ir3_compiler *compiler,
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct nir_shader *
|
struct nir_shader *
|
||||||
ir3_tgsi_to_nir(struct ir3_compiler *compiler, const struct tgsi_token *tokens)
|
ir3_tgsi_to_nir(struct ir3_compiler *compiler,
|
||||||
|
const struct tgsi_token *tokens,
|
||||||
|
struct pipe_screen *screen)
|
||||||
{
|
{
|
||||||
|
/* TODO: pass screen to tgsi_to_nir when it needs that. */
|
||||||
|
(void) screen;
|
||||||
return tgsi_to_nir(tokens, ir3_get_compiler_options(compiler));
|
return tgsi_to_nir(tokens, ir3_get_compiler_options(compiler));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -28,20 +28,24 @@
|
|||||||
#define IR3_GALLIUM_H_
|
#define IR3_GALLIUM_H_
|
||||||
|
|
||||||
#include "pipe/p_state.h"
|
#include "pipe/p_state.h"
|
||||||
|
#include "pipe/p_screen.h"
|
||||||
#include "ir3/ir3_shader.h"
|
#include "ir3/ir3_shader.h"
|
||||||
|
|
||||||
struct ir3_shader * ir3_shader_create(struct ir3_compiler *compiler,
|
struct ir3_shader * ir3_shader_create(struct ir3_compiler *compiler,
|
||||||
const struct pipe_shader_state *cso, gl_shader_stage type,
|
const struct pipe_shader_state *cso, gl_shader_stage type,
|
||||||
struct pipe_debug_callback *debug);
|
struct pipe_debug_callback *debug,
|
||||||
|
struct pipe_screen *screen);
|
||||||
struct ir3_shader *
|
struct ir3_shader *
|
||||||
ir3_shader_create_compute(struct ir3_compiler *compiler,
|
ir3_shader_create_compute(struct ir3_compiler *compiler,
|
||||||
const struct pipe_compute_state *cso,
|
const struct pipe_compute_state *cso,
|
||||||
struct pipe_debug_callback *debug);
|
struct pipe_debug_callback *debug,
|
||||||
|
struct pipe_screen *screen);
|
||||||
struct ir3_shader_variant * ir3_shader_variant(struct ir3_shader *shader,
|
struct ir3_shader_variant * ir3_shader_variant(struct ir3_shader *shader,
|
||||||
struct ir3_shader_key key, bool binning_pass,
|
struct ir3_shader_key key, bool binning_pass,
|
||||||
struct pipe_debug_callback *debug);
|
struct pipe_debug_callback *debug);
|
||||||
struct nir_shader * ir3_tgsi_to_nir(struct ir3_compiler *compiler,
|
struct nir_shader * ir3_tgsi_to_nir(struct ir3_compiler *compiler,
|
||||||
const struct tgsi_token *tokens);
|
const struct tgsi_token *tokens,
|
||||||
|
struct pipe_screen *screen);
|
||||||
|
|
||||||
struct fd_ringbuffer;
|
struct fd_ringbuffer;
|
||||||
struct fd_context;
|
struct fd_context;
|
||||||
|
Reference in New Issue
Block a user