#include <stdint.h>
+#include "compiler/nir/nir.h"
+#include "compiler/nir/nir_builder.h"
+
#include "pipe/p_defines.h"
#include "util/u_inlines.h"
#include "util/u_pack_color.h"
#include "util/format/u_format.h"
#include "util/u_surface.h"
-
-#include "tgsi/tgsi_ureg.h"
-
#include "util/u_thread.h"
+#include "nv50_ir_driver.h"
+
#include "nvc0/nvc0_context.h"
#include "nvc0/nvc0_resource.h"
static void *
nvc0_blitter_make_vp(struct pipe_context *pipe)
{
- struct ureg_program *ureg;
- struct ureg_src ipos, itex;
- struct ureg_dst opos, otex;
-
- ureg = ureg_create(PIPE_SHADER_VERTEX);
- if (!ureg)
- return NULL;
-
- opos = ureg_DECL_output(ureg, TGSI_SEMANTIC_POSITION, 0);
- ipos = ureg_DECL_vs_input(ureg, 0);
- otex = ureg_DECL_output(ureg, TGSI_SEMANTIC_GENERIC, 0);
- itex = ureg_DECL_vs_input(ureg, 1);
-
- ureg_MOV(ureg, ureg_writemask(opos, TGSI_WRITEMASK_XY ), ipos);
- ureg_MOV(ureg, ureg_writemask(otex, TGSI_WRITEMASK_XYZ), itex);
- ureg_END(ureg);
-
- return ureg_create_shader_and_destroy(ureg, pipe);
+ const nir_shader_compiler_options *options =
+ nv50_ir_nir_shader_compiler_options(nouveau_screen(pipe->screen)->device->chipset,
+ PIPE_SHADER_VERTEX, true);
+
+ struct nir_builder b =
+ nir_builder_init_simple_shader(MESA_SHADER_VERTEX, options,
+ "blitter_vp");
+
+ const struct glsl_type* float2 = glsl_vector_type(GLSL_TYPE_FLOAT, 2);
+ const struct glsl_type* float3 = glsl_vector_type(GLSL_TYPE_FLOAT, 3);
+
+ nir_variable *ipos =
+ nir_variable_create(b.shader, nir_var_shader_in, float2, "ipos");
+ ipos->data.location = VERT_ATTRIB_GENERIC0;
+ ipos->data.driver_location = 0;
+
+ nir_variable *opos =
+ nir_variable_create(b.shader, nir_var_shader_out, float2, "opos");
+ opos->data.location = VARYING_SLOT_POS;
+ opos->data.driver_location = 0;
+
+ nir_variable *itex =
+ nir_variable_create(b.shader, nir_var_shader_in, float3, "itex");
+ itex->data.location = VERT_ATTRIB_GENERIC1;
+ itex->data.driver_location = 1;
+
+ nir_variable *otex =
+ nir_variable_create(b.shader, nir_var_shader_out, float3, "otex");
+ otex->data.location = VARYING_SLOT_VAR0;
+ otex->data.driver_location = 1;
+
+ nir_copy_var(&b, opos, ipos);
+ nir_copy_var(&b, otex, itex);
+
+ NIR_PASS_V(b.shader, nir_lower_var_copies);
+
+ struct pipe_shader_state state = {};
+ state.type = PIPE_SHADER_IR_NIR;
+ state.ir.nir = b.shader;
+ return pipe->create_vs_state(pipe, &state);
}
static void