diff options
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/auxiliary/nir/tgsi_to_nir.c | 102 | ||||
-rw-r--r-- | src/gallium/drivers/nouveau/codegen/nv50_ir.cpp | 62 | ||||
-rw-r--r-- | src/gallium/drivers/nouveau/codegen/nv50_ir.h | 2 | ||||
-rw-r--r-- | src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp | 68 | ||||
-rw-r--r-- | src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp | 64 |
5 files changed, 70 insertions, 228 deletions
diff --git a/src/gallium/auxiliary/nir/tgsi_to_nir.c b/src/gallium/auxiliary/nir/tgsi_to_nir.c index bd59949da5c..8463e02d5e0 100644 --- a/src/gallium/auxiliary/nir/tgsi_to_nir.c +++ b/src/gallium/auxiliary/nir/tgsi_to_nir.c @@ -1345,7 +1345,7 @@ get_image_var(struct ttn_compile *c, int binding, bool is_array, enum glsl_base_type base_type, enum gl_access_qualifier access, - GLenum format) + enum pipe_format format) { nir_variable *var = c->images[binding]; @@ -1741,102 +1741,6 @@ get_mem_qualifier(struct tgsi_full_instruction *tgsi_inst) return access; } -static GLenum -get_image_format(struct tgsi_full_instruction *tgsi_inst) -{ - switch (tgsi_inst->Memory.Format) { - case PIPE_FORMAT_NONE: - return GL_NONE; - - case PIPE_FORMAT_R8_UNORM: - return GL_R8; - case PIPE_FORMAT_R8G8_UNORM: - return GL_RG8; - case PIPE_FORMAT_R8G8B8A8_UNORM: - return GL_RGBA8; - case PIPE_FORMAT_R16_UNORM: - return GL_R16; - case PIPE_FORMAT_R16G16_UNORM: - return GL_RG16; - case PIPE_FORMAT_R16G16B16A16_UNORM: - return GL_RGBA16; - - case PIPE_FORMAT_R8_SNORM: - return GL_R8_SNORM; - case PIPE_FORMAT_R8G8_SNORM: - return GL_RG8_SNORM; - case PIPE_FORMAT_R8G8B8A8_SNORM: - return GL_RGBA8_SNORM; - case PIPE_FORMAT_R16_SNORM: - return GL_R16_SNORM; - case PIPE_FORMAT_R16G16_SNORM: - return GL_RG16_SNORM; - case PIPE_FORMAT_R16G16B16A16_SNORM: - return GL_RGBA16_SNORM; - - case PIPE_FORMAT_R8_UINT: - return GL_R8UI; - case PIPE_FORMAT_R8G8_UINT: - return GL_RG8UI; - case PIPE_FORMAT_R8G8B8A8_UINT: - return GL_RGBA8UI; - case PIPE_FORMAT_R16_UINT: - return GL_R16UI; - case PIPE_FORMAT_R16G16_UINT: - return GL_RG16UI; - case PIPE_FORMAT_R16G16B16A16_UINT: - return GL_RGBA16UI; - case PIPE_FORMAT_R32_UINT: - return GL_R32UI; - case PIPE_FORMAT_R32G32_UINT: - return GL_RG32UI; - case PIPE_FORMAT_R32G32B32A32_UINT: - return GL_RGBA32UI; - - case PIPE_FORMAT_R8_SINT: - return GL_R8I; - case PIPE_FORMAT_R8G8_SINT: - return GL_RG8I; - case PIPE_FORMAT_R8G8B8A8_SINT: - return GL_RGBA8I; - case PIPE_FORMAT_R16_SINT: - return GL_R16I; - case PIPE_FORMAT_R16G16_SINT: - return GL_RG16I; - case PIPE_FORMAT_R16G16B16A16_SINT: - return GL_RGBA16I; - case PIPE_FORMAT_R32_SINT: - return GL_R32I; - case PIPE_FORMAT_R32G32_SINT: - return GL_RG32I; - case PIPE_FORMAT_R32G32B32A32_SINT: - return GL_RGBA32I; - - case PIPE_FORMAT_R16_FLOAT: - return GL_R16F; - case PIPE_FORMAT_R16G16_FLOAT: - return GL_RG16F; - case PIPE_FORMAT_R16G16B16A16_FLOAT: - return GL_RGBA16F; - case PIPE_FORMAT_R32_FLOAT: - return GL_R32F; - case PIPE_FORMAT_R32G32_FLOAT: - return GL_RG32F; - case PIPE_FORMAT_R32G32B32A32_FLOAT: - return GL_RGBA32F; - - case PIPE_FORMAT_R11G11B10_FLOAT: - return GL_R11F_G11F_B10F; - case PIPE_FORMAT_R10G10B10A2_UINT: - return GL_RGB10_A2UI; - case PIPE_FORMAT_R10G10B10A2_UNORM: - return GL_RGB10_A2; - - default: - unreachable("unhandled image format"); - } -} - static void ttn_mem(struct ttn_compile *c, nir_alu_dest dest, nir_ssa_def **src) { @@ -1912,11 +1816,11 @@ ttn_mem(struct ttn_compile *c, nir_alu_dest dest, nir_ssa_def **src) enum glsl_base_type base_type = get_image_base_type(tgsi_inst); enum gl_access_qualifier access = get_mem_qualifier(tgsi_inst); - GLenum format = get_image_format(tgsi_inst); nir_variable *image = get_image_var(c, resource_index, - dim, is_array, base_type, access, format); + dim, is_array, base_type, access, + tgsi_inst->Memory.Format); nir_deref_instr *image_deref = nir_build_deref_var(b, image); const struct glsl_type *type = image_deref->type; diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir.cpp index ae07d967221..c65853578f6 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir.cpp +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir.cpp @@ -1024,6 +1024,68 @@ const struct TexInstruction::ImgFormatDesc TexInstruction::formatTable[] = { "BGRA8", 4, { 8, 8, 8, 8 }, UNORM, true }, }; +const struct TexInstruction::ImgFormatDesc * +TexInstruction::translateImgFormat(enum pipe_format format) +{ + +#define FMT_CASE(a, b) \ + case PIPE_FORMAT_ ## a: return &formatTable[nv50_ir::FMT_ ## b] + + switch (format) { + FMT_CASE(NONE, NONE); + + FMT_CASE(R32G32B32A32_FLOAT, RGBA32F); + FMT_CASE(R16G16B16A16_FLOAT, RGBA16F); + FMT_CASE(R32G32_FLOAT, RG32F); + FMT_CASE(R16G16_FLOAT, RG16F); + FMT_CASE(R11G11B10_FLOAT, R11G11B10F); + FMT_CASE(R32_FLOAT, R32F); + FMT_CASE(R16_FLOAT, R16F); + + FMT_CASE(R32G32B32A32_UINT, RGBA32UI); + FMT_CASE(R16G16B16A16_UINT, RGBA16UI); + FMT_CASE(R10G10B10A2_UINT, RGB10A2UI); + FMT_CASE(R8G8B8A8_UINT, RGBA8UI); + FMT_CASE(R32G32_UINT, RG32UI); + FMT_CASE(R16G16_UINT, RG16UI); + FMT_CASE(R8G8_UINT, RG8UI); + FMT_CASE(R32_UINT, R32UI); + FMT_CASE(R16_UINT, R16UI); + FMT_CASE(R8_UINT, R8UI); + + FMT_CASE(R32G32B32A32_SINT, RGBA32I); + FMT_CASE(R16G16B16A16_SINT, RGBA16I); + FMT_CASE(R8G8B8A8_SINT, RGBA8I); + FMT_CASE(R32G32_SINT, RG32I); + FMT_CASE(R16G16_SINT, RG16I); + FMT_CASE(R8G8_SINT, RG8I); + FMT_CASE(R32_SINT, R32I); + FMT_CASE(R16_SINT, R16I); + FMT_CASE(R8_SINT, R8I); + + FMT_CASE(R16G16B16A16_UNORM, RGBA16); + FMT_CASE(R10G10B10A2_UNORM, RGB10A2); + FMT_CASE(R8G8B8A8_UNORM, RGBA8); + FMT_CASE(R16G16_UNORM, RG16); + FMT_CASE(R8G8_UNORM, RG8); + FMT_CASE(R16_UNORM, R16); + FMT_CASE(R8_UNORM, R8); + + FMT_CASE(R16G16B16A16_SNORM, RGBA16_SNORM); + FMT_CASE(R8G8B8A8_SNORM, RGBA8_SNORM); + FMT_CASE(R16G16_SNORM, RG16_SNORM); + FMT_CASE(R8G8_SNORM, RG8_SNORM); + FMT_CASE(R16_SNORM, R16_SNORM); + FMT_CASE(R8_SNORM, R8_SNORM); + + FMT_CASE(B8G8R8A8_UNORM, BGRA8); + + default: + assert(!"Unexpected format"); + return &formatTable[nv50_ir::FMT_NONE]; + } +} + void TexInstruction::setIndirectR(Value *v) { diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir.h b/src/gallium/drivers/nouveau/codegen/nv50_ir.h index b19751ab372..296b79f5d49 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir.h +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir.h @@ -1016,6 +1016,8 @@ public: }; static const struct ImgFormatDesc formatTable[IMG_FORMAT_COUNT]; + static const struct ImgFormatDesc *translateImgFormat( + enum pipe_format format); public: TexInstruction(Function *, operation); diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp index 22dbbae4a92..c2b9f2043bf 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp @@ -81,8 +81,6 @@ private: LValues& convert(nir_register *); LValues& convert(nir_ssa_def *); - ImgFormat convertGLImgFormat(GLuint); - Value* getSrc(nir_alu_src *, uint8_t component = 0); Value* getSrc(nir_register *, uint8_t); Value* getSrc(nir_src *, uint8_t, bool indirect = false); @@ -1860,68 +1858,6 @@ Converter::convert(nir_intrinsic_op intr) } } -ImgFormat -Converter::convertGLImgFormat(GLuint format) -{ -#define FMT_CASE(a, b) \ - case GL_ ## a: return nv50_ir::FMT_ ## b - - switch (format) { - FMT_CASE(NONE, NONE); - - FMT_CASE(RGBA32F, RGBA32F); - FMT_CASE(RGBA16F, RGBA16F); - FMT_CASE(RG32F, RG32F); - FMT_CASE(RG16F, RG16F); - FMT_CASE(R11F_G11F_B10F, R11G11B10F); - FMT_CASE(R32F, R32F); - FMT_CASE(R16F, R16F); - - FMT_CASE(RGBA32UI, RGBA32UI); - FMT_CASE(RGBA16UI, RGBA16UI); - FMT_CASE(RGB10_A2UI, RGB10A2UI); - FMT_CASE(RGBA8UI, RGBA8UI); - FMT_CASE(RG32UI, RG32UI); - FMT_CASE(RG16UI, RG16UI); - FMT_CASE(RG8UI, RG8UI); - FMT_CASE(R32UI, R32UI); - FMT_CASE(R16UI, R16UI); - FMT_CASE(R8UI, R8UI); - - FMT_CASE(RGBA32I, RGBA32I); - FMT_CASE(RGBA16I, RGBA16I); - FMT_CASE(RGBA8I, RGBA8I); - FMT_CASE(RG32I, RG32I); - FMT_CASE(RG16I, RG16I); - FMT_CASE(RG8I, RG8I); - FMT_CASE(R32I, R32I); - FMT_CASE(R16I, R16I); - FMT_CASE(R8I, R8I); - - FMT_CASE(RGBA16, RGBA16); - FMT_CASE(RGB10_A2, RGB10A2); - FMT_CASE(RGBA8, RGBA8); - FMT_CASE(RG16, RG16); - FMT_CASE(RG8, RG8); - FMT_CASE(R16, R16); - FMT_CASE(R8, R8); - - FMT_CASE(RGBA16_SNORM, RGBA16_SNORM); - FMT_CASE(RGBA8_SNORM, RGBA8_SNORM); - FMT_CASE(RG16_SNORM, RG16_SNORM); - FMT_CASE(RG8_SNORM, RG8_SNORM); - FMT_CASE(R16_SNORM, R16_SNORM); - FMT_CASE(R8_SNORM, R8_SNORM); - - FMT_CASE(BGRA_INTEGER, BGRA8); - default: - ERROR("unknown format %x\n", format); - assert(false); - return nv50_ir::FMT_NONE; - } -#undef FMT_CASE -} - bool Converter::visit(nir_intrinsic_instr *insn) { @@ -2502,7 +2438,7 @@ Converter::visit(nir_intrinsic_instr *insn) TexInstruction *texi = mkTex(getOperation(op), target.getEnum(), location, 0, defs, srcs); texi->tex.bindless = false; - texi->tex.format = &nv50_ir::TexInstruction::formatTable[convertGLImgFormat(nir_intrinsic_format(insn))]; + texi->tex.format = nv50_ir::TexInstruction::translateImgFormat(nir_intrinsic_format(insn)); texi->tex.mask = mask; texi->tex.bindless = true; texi->cache = convert(nir_intrinsic_access(insn)); @@ -2608,7 +2544,7 @@ Converter::visit(nir_intrinsic_instr *insn) TexInstruction *texi = mkTex(getOperation(op), target.getEnum(), location, 0, defs, srcs); texi->tex.bindless = false; - texi->tex.format = &nv50_ir::TexInstruction::formatTable[convertGLImgFormat(tex->data.image.format)]; + texi->tex.format = nv50_ir::TexInstruction::translateImgFormat(tex->data.image.format); texi->tex.mask = mask; texi->cache = getCacheModeFromVar(tex); texi->setType(ty); diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp index 8c429026452..da9df42e232 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp @@ -40,7 +40,6 @@ static nv50_ir::DataFile translateFile(uint file); static nv50_ir::TexTarget translateTexture(uint texTarg); static nv50_ir::SVSemantic translateSysVal(uint sysval); static nv50_ir::CacheMode translateCacheMode(uint qualifier); -static nv50_ir::ImgFormat translateImgFormat(uint format); class Instruction { @@ -224,8 +223,7 @@ public: nv50_ir::TexInstruction::Target getTexture(const Source *, int s) const; const nv50_ir::TexInstruction::ImgFormatDesc *getImageFormat() const { - return &nv50_ir::TexInstruction::formatTable[ - translateImgFormat(insn->Memory.Format)]; + return nv50_ir::TexInstruction::translateImgFormat((enum pipe_format)insn->Memory.Format); } nv50_ir::TexTarget getImageTarget() const { @@ -513,66 +511,6 @@ static nv50_ir::CacheMode translateCacheMode(uint qualifier) return nv50_ir::CACHE_CA; } -static nv50_ir::ImgFormat translateImgFormat(uint format) -{ - -#define FMT_CASE(a, b) \ - case PIPE_FORMAT_ ## a: return nv50_ir::FMT_ ## b - - switch (format) { - FMT_CASE(NONE, NONE); - - FMT_CASE(R32G32B32A32_FLOAT, RGBA32F); - FMT_CASE(R16G16B16A16_FLOAT, RGBA16F); - FMT_CASE(R32G32_FLOAT, RG32F); - FMT_CASE(R16G16_FLOAT, RG16F); - FMT_CASE(R11G11B10_FLOAT, R11G11B10F); - FMT_CASE(R32_FLOAT, R32F); - FMT_CASE(R16_FLOAT, R16F); - - FMT_CASE(R32G32B32A32_UINT, RGBA32UI); - FMT_CASE(R16G16B16A16_UINT, RGBA16UI); - FMT_CASE(R10G10B10A2_UINT, RGB10A2UI); - FMT_CASE(R8G8B8A8_UINT, RGBA8UI); - FMT_CASE(R32G32_UINT, RG32UI); - FMT_CASE(R16G16_UINT, RG16UI); - FMT_CASE(R8G8_UINT, RG8UI); - FMT_CASE(R32_UINT, R32UI); - FMT_CASE(R16_UINT, R16UI); - FMT_CASE(R8_UINT, R8UI); - - FMT_CASE(R32G32B32A32_SINT, RGBA32I); - FMT_CASE(R16G16B16A16_SINT, RGBA16I); - FMT_CASE(R8G8B8A8_SINT, RGBA8I); - FMT_CASE(R32G32_SINT, RG32I); - FMT_CASE(R16G16_SINT, RG16I); - FMT_CASE(R8G8_SINT, RG8I); - FMT_CASE(R32_SINT, R32I); - FMT_CASE(R16_SINT, R16I); - FMT_CASE(R8_SINT, R8I); - - FMT_CASE(R16G16B16A16_UNORM, RGBA16); - FMT_CASE(R10G10B10A2_UNORM, RGB10A2); - FMT_CASE(R8G8B8A8_UNORM, RGBA8); - FMT_CASE(R16G16_UNORM, RG16); - FMT_CASE(R8G8_UNORM, RG8); - FMT_CASE(R16_UNORM, R16); - FMT_CASE(R8_UNORM, R8); - - FMT_CASE(R16G16B16A16_SNORM, RGBA16_SNORM); - FMT_CASE(R8G8B8A8_SNORM, RGBA8_SNORM); - FMT_CASE(R16G16_SNORM, RG16_SNORM); - FMT_CASE(R8G8_SNORM, RG8_SNORM); - FMT_CASE(R16_SNORM, R16_SNORM); - FMT_CASE(R8_SNORM, R8_SNORM); - - FMT_CASE(B8G8R8A8_UNORM, BGRA8); - } - - assert(!"Unexpected format"); - return nv50_ir::FMT_NONE; -} - nv50_ir::DataType Instruction::inferSrcType() const { switch (getOpcode()) { |