Also, swap vs and fs constructor or so fs comes first.
Signed-off-by: Kristian H. Kristensen <hoegsberg@google.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
#include "fd3_texture.h"
#include "fd3_format.h"
-static struct ir3_shader *
-create_shader_stateobj(struct pipe_context *pctx, const struct pipe_shader_state *cso,
- gl_shader_stage type)
-{
- struct fd_context *ctx = fd_context(pctx);
- struct ir3_compiler *compiler = ctx->screen->compiler;
- return ir3_shader_create(compiler, cso, type, &ctx->debug, pctx->screen);
-}
-
-static void *
-fd3_fp_state_create(struct pipe_context *pctx,
- const struct pipe_shader_state *cso)
-{
- return create_shader_stateobj(pctx, cso, MESA_SHADER_FRAGMENT);
-}
-
-static void
-fd3_fp_state_delete(struct pipe_context *pctx, void *hwcso)
-{
- struct ir3_shader *so = hwcso;
- ir3_shader_destroy(so);
-}
-
-static void *
-fd3_vp_state_create(struct pipe_context *pctx,
- const struct pipe_shader_state *cso)
-{
- return create_shader_stateobj(pctx, cso, MESA_SHADER_VERTEX);
-}
-
-static void
-fd3_vp_state_delete(struct pipe_context *pctx, void *hwcso)
-{
- struct ir3_shader *so = hwcso;
- ir3_shader_destroy(so);
-}
-
bool
fd3_needs_manual_clipping(const struct ir3_shader *shader,
const struct pipe_rasterizer_state *rast)
void
fd3_prog_init(struct pipe_context *pctx)
{
- pctx->create_fs_state = fd3_fp_state_create;
- pctx->delete_fs_state = fd3_fp_state_delete;
-
- pctx->create_vs_state = fd3_vp_state_create;
- pctx->delete_vs_state = fd3_vp_state_delete;
-
+ ir3_prog_init(pctx);
fd_prog_init(pctx);
}
#include "fd4_texture.h"
#include "fd4_format.h"
-static struct ir3_shader *
-create_shader_stateobj(struct pipe_context *pctx, const struct pipe_shader_state *cso,
- gl_shader_stage type)
-{
- struct fd_context *ctx = fd_context(pctx);
- struct ir3_compiler *compiler = ctx->screen->compiler;
- return ir3_shader_create(compiler, cso, type, &ctx->debug, pctx->screen);
-}
-
-static void *
-fd4_fp_state_create(struct pipe_context *pctx,
- const struct pipe_shader_state *cso)
-{
- return create_shader_stateobj(pctx, cso, MESA_SHADER_FRAGMENT);
-}
-
-static void
-fd4_fp_state_delete(struct pipe_context *pctx, void *hwcso)
-{
- struct ir3_shader *so = hwcso;
- ir3_shader_destroy(so);
-}
-
-static void *
-fd4_vp_state_create(struct pipe_context *pctx,
- const struct pipe_shader_state *cso)
-{
- return create_shader_stateobj(pctx, cso, MESA_SHADER_VERTEX);
-}
-
-static void
-fd4_vp_state_delete(struct pipe_context *pctx, void *hwcso)
-{
- struct ir3_shader *so = hwcso;
- ir3_shader_destroy(so);
-}
-
static void
emit_shader(struct fd_ringbuffer *ring, const struct ir3_shader_variant *so)
{
void
fd4_prog_init(struct pipe_context *pctx)
{
- pctx->create_fs_state = fd4_fp_state_create;
- pctx->delete_fs_state = fd4_fp_state_delete;
-
- pctx->create_vs_state = fd4_vp_state_create;
- pctx->delete_vs_state = fd4_vp_state_delete;
-
+ ir3_prog_init(pctx);
fd_prog_init(pctx);
}
#include "ir3_cache.h"
-static struct ir3_shader *
-create_shader_stateobj(struct pipe_context *pctx, const struct pipe_shader_state *cso,
- gl_shader_stage type)
-{
- struct fd_context *ctx = fd_context(pctx);
- struct ir3_compiler *compiler = ctx->screen->compiler;
- return ir3_shader_create(compiler, cso, type, &ctx->debug, pctx->screen);
-}
-
-static void *
-fd5_fp_state_create(struct pipe_context *pctx,
- const struct pipe_shader_state *cso)
-{
- return create_shader_stateobj(pctx, cso, MESA_SHADER_FRAGMENT);
-}
-
-static void
-fd5_fp_state_delete(struct pipe_context *pctx, void *hwcso)
-{
- struct ir3_shader *so = hwcso;
- ir3_shader_destroy(so);
-}
-
-static void *
-fd5_vp_state_create(struct pipe_context *pctx,
- const struct pipe_shader_state *cso)
-{
- return create_shader_stateobj(pctx, cso, MESA_SHADER_VERTEX);
-}
-
-static void
-fd5_vp_state_delete(struct pipe_context *pctx, void *hwcso)
-{
- struct ir3_shader *so = hwcso;
- ir3_shader_destroy(so);
-}
-
void
fd5_emit_shader(struct fd_ringbuffer *ring, const struct ir3_shader_variant *so)
{
void
fd5_prog_init(struct pipe_context *pctx)
{
- pctx->create_fs_state = fd5_fp_state_create;
- pctx->delete_fs_state = fd5_fp_state_delete;
-
- pctx->create_vs_state = fd5_vp_state_create;
- pctx->delete_vs_state = fd5_vp_state_delete;
-
+ ir3_prog_init(pctx);
fd_prog_init(pctx);
}
#include "fd6_texture.h"
#include "fd6_format.h"
-static struct ir3_shader *
-create_shader_stateobj(struct pipe_context *pctx, const struct pipe_shader_state *cso,
- gl_shader_stage type)
-{
- struct fd_context *ctx = fd_context(pctx);
- struct ir3_compiler *compiler = ctx->screen->compiler;
- struct ir3_shader *shader =
- ir3_shader_create(compiler, cso, type, &ctx->debug, pctx->screen);
- unsigned packets, size;
-
- /* pre-calculate size required for userconst stateobj: */
- ir3_user_consts_size(&shader->ubo_state, &packets, &size);
-
- /* also account for UBO addresses: */
- packets += 1;
- size += 2 * shader->const_state.num_ubos;
-
- unsigned sizedwords = (4 * packets) + size;
- shader->ubo_state.cmdstream_size = sizedwords * 4;
-
- return shader;
-}
-
-static void *
-fd6_fp_state_create(struct pipe_context *pctx,
- const struct pipe_shader_state *cso)
-{
- return create_shader_stateobj(pctx, cso, MESA_SHADER_FRAGMENT);
-}
-
-static void
-fd6_fp_state_delete(struct pipe_context *pctx, void *hwcso)
-{
- struct ir3_shader *so = hwcso;
- struct fd_context *ctx = fd_context(pctx);
- ir3_cache_invalidate(fd6_context(ctx)->shader_cache, hwcso);
- ir3_shader_destroy(so);
-}
-
-static void *
-fd6_vp_state_create(struct pipe_context *pctx,
- const struct pipe_shader_state *cso)
-{
- return create_shader_stateobj(pctx, cso, MESA_SHADER_VERTEX);
-}
-
-static void
-fd6_vp_state_delete(struct pipe_context *pctx, void *hwcso)
-{
- struct ir3_shader *so = hwcso;
- struct fd_context *ctx = fd_context(pctx);
- ir3_cache_invalidate(fd6_context(ctx)->shader_cache, hwcso);
- ir3_shader_destroy(so);
-}
-
void
fd6_emit_shader(struct fd_ringbuffer *ring, const struct ir3_shader_variant *so)
{
.destroy_state = fd6_program_destroy,
};
+static void *
+fd6_shader_state_create(struct pipe_context *pctx, const struct pipe_shader_state *cso)
+{
+ struct fd_context *ctx = fd_context(pctx);
+ struct ir3_compiler *compiler = ctx->screen->compiler;
+ struct ir3_shader *shader =
+ ir3_shader_create(compiler, cso, &ctx->debug, pctx->screen);
+ unsigned packets, size;
+
+ /* pre-calculate size required for userconst stateobj: */
+ ir3_user_consts_size(&shader->ubo_state, &packets, &size);
+
+ /* also account for UBO addresses: */
+ packets += 1;
+ size += 2 * shader->const_state.num_ubos;
+
+ unsigned sizedwords = (4 * packets) + size;
+ shader->ubo_state.cmdstream_size = sizedwords * 4;
+
+ return shader;
+}
+
+static void
+fd6_shader_state_delete(struct pipe_context *pctx, void *hwcso)
+{
+ struct ir3_shader *so = hwcso;
+ struct fd_context *ctx = fd_context(pctx);
+ ir3_cache_invalidate(fd6_context(ctx)->shader_cache, hwcso);
+ ir3_shader_destroy(so);
+}
+
void
fd6_prog_init(struct pipe_context *pctx)
{
fd6_context(ctx)->shader_cache = ir3_cache_create(&cache_funcs, ctx);
- pctx->create_fs_state = fd6_fp_state_create;
- pctx->delete_fs_state = fd6_fp_state_delete;
+ pctx->create_vs_state = fd6_shader_state_create;
+ pctx->delete_vs_state = fd6_shader_state_delete;
- pctx->create_vs_state = fd6_vp_state_create;
- pctx->delete_vs_state = fd6_vp_state_delete;
+ pctx->create_fs_state = fd6_shader_state_create;
+ pctx->delete_fs_state = fd6_shader_state_delete;
fd_prog_init(pctx);
}
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,
struct pipe_debug_callback *debug,
struct pipe_screen *screen)
{
}
}
}
+
+static void *
+ir3_shader_state_create(struct pipe_context *pctx, const struct pipe_shader_state *cso)
+{
+ struct fd_context *ctx = fd_context(pctx);
+ struct ir3_compiler *compiler = ctx->screen->compiler;
+ return ir3_shader_create(compiler, cso, &ctx->debug, pctx->screen);
+}
+
+static void
+ir3_shader_state_delete(struct pipe_context *pctx, void *hwcso)
+{
+ struct ir3_shader *so = hwcso;
+ ir3_shader_destroy(so);
+}
+
+void
+ir3_prog_init(struct pipe_context *pctx)
+{
+ pctx->create_vs_state = ir3_shader_state_create;
+ pctx->delete_vs_state = ir3_shader_state_delete;
+
+ pctx->create_tcs_state = ir3_shader_state_create;
+ pctx->delete_tcs_state = ir3_shader_state_delete;
+
+ pctx->create_tes_state = ir3_shader_state_create;
+ pctx->delete_tes_state = ir3_shader_state_delete;
+
+ pctx->create_gs_state = ir3_shader_state_create;
+ pctx->delete_gs_state = ir3_shader_state_delete;
+
+ pctx->create_fs_state = ir3_shader_state_create;
+ pctx->delete_fs_state = ir3_shader_state_delete;
+}
#include "ir3/ir3_shader.h"
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,
struct pipe_debug_callback *debug,
struct pipe_screen *screen);
struct ir3_shader *
void ir3_emit_cs_consts(const struct ir3_shader_variant *v, struct fd_ringbuffer *ring,
struct fd_context *ctx, const struct pipe_grid_info *info);
+void ir3_prog_init(struct pipe_context *pctx);
+
#endif /* IR3_GALLIUM_H_ */