Last active
February 13, 2019 23:55
-
-
Save nkreeger/d4e03b7d9fbd4a19f6ebf6ef74855367 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/gallium/drivers/svga/svga_screen.c b/src/gallium/drivers/svga/svga_screen.c | |
index 6cb5a14f5b0..2be26d18f0d 100644 | |
--- a/src/gallium/drivers/svga/svga_screen.c | |
+++ b/src/gallium/drivers/svga/svga_screen.c | |
@@ -353,6 +353,10 @@ svga_get_param(struct pipe_screen *screen, enum pipe_cap param) | |
case PIPE_CAP_MAX_VARYINGS: | |
return sws->have_vgpu10 ? VGPU10_MAX_FS_INPUTS : 10; | |
+ case PIPE_CAP_TEXTURE_FLOAT_LINEAR: | |
+ case PIPE_CAP_TEXTURE_HALF_FLOAT_LINEAR: | |
+ return 1; | |
+ | |
/* Unsupported features */ | |
case PIPE_CAP_TEXTURE_MIRROR_CLAMP: | |
case PIPE_CAP_TEXTURE_MIRROR_CLAMP_TO_EDGE: | |
@@ -429,8 +433,6 @@ svga_get_param(struct pipe_screen *screen, enum pipe_cap param) | |
case PIPE_CAP_RESOURCE_FROM_USER_MEMORY: | |
case PIPE_CAP_DEVICE_RESET_STATUS_QUERY: | |
case PIPE_CAP_MAX_SHADER_PATCH_VARYINGS: | |
- case PIPE_CAP_TEXTURE_FLOAT_LINEAR: | |
- case PIPE_CAP_TEXTURE_HALF_FLOAT_LINEAR: | |
case PIPE_CAP_DEPTH_BOUNDS_TEST: | |
case PIPE_CAP_TGSI_TXQS: | |
case PIPE_CAP_SHAREABLE_SHADERS: | |
diff --git a/src/gallium/drivers/vc4/kernel/vc4_validate.c b/src/gallium/drivers/vc4/kernel/vc4_validate.c | |
index bd193b993b3..f4155c9e0b4 100644 | |
--- a/src/gallium/drivers/vc4/kernel/vc4_validate.c | |
+++ b/src/gallium/drivers/vc4/kernel/vc4_validate.c | |
@@ -647,10 +647,12 @@ reloc_tex(struct vc4_exec_info *exec, | |
width = (width + 3) >> 2; | |
height = (height + 3) >> 2; | |
break; | |
+ case VC4_TEXTURE_TYPE_RGBA64: | |
+ cpp = 8; | |
+ break; | |
case VC4_TEXTURE_TYPE_BW1: | |
case VC4_TEXTURE_TYPE_A4: | |
case VC4_TEXTURE_TYPE_A1: | |
- case VC4_TEXTURE_TYPE_RGBA64: | |
case VC4_TEXTURE_TYPE_YUV422R: | |
default: | |
DRM_ERROR("Texture format %d unsupported\n", type); | |
diff --git a/src/gallium/drivers/vc4/vc4_formats.c b/src/gallium/drivers/vc4/vc4_formats.c | |
index 6d4a6249fbf..cb971994aa8 100644 | |
--- a/src/gallium/drivers/vc4/vc4_formats.c | |
+++ b/src/gallium/drivers/vc4/vc4_formats.c | |
@@ -40,12 +40,13 @@ | |
#define RT_NO 0 | |
#define RT_RGBA8888 1 | |
#define RT_RGB565 2 | |
+#define RT_RGBA16F 3 | |
struct vc4_format { | |
/** Set if the pipe format is defined in the table. */ | |
bool present; | |
- /** Set to 0 if unsupported, 1 if RGBA8888, 2 if rgb565. */ | |
+ /** Set to 0 if unsupported, 1 if RGBA8888, 2 if rgb565, 3 if RGBA16F */ | |
uint8_t rt_type; | |
/** One of VC4_TEXTURE_TYPE_*. */ | |
@@ -58,6 +59,9 @@ struct vc4_format { | |
* value into shader rgba values. | |
*/ | |
uint8_t swizzle[4]; | |
+ | |
+ /* Whether the return value is 16F/I/UI or 32F/I/UI. */ | |
+ uint8_t return_size; | |
}; | |
#define SWIZ(x,y,z,w) { \ | |
@@ -104,6 +108,8 @@ static const struct vc4_format vc4_format_table[] = { | |
FORMAT(L8A8_UNORM, NO, LUMALPHA, SWIZ(X, X, X, W)), | |
FORMAT(R8G8_UNORM, NO, LUMALPHA, SWIZ(X, W, 0, 1)), | |
+ | |
+ FORMAT(R16G16B16A16_FLOAT, RGBA16F, RGBA64, SWIZ(X, Y, Z, W)), | |
}; | |
static const struct vc4_format * | |
diff --git a/src/gallium/drivers/vc4/vc4_program.c b/src/gallium/drivers/vc4/vc4_program.c | |
index 2d0a52bb5fb..e97c48a4650 100644 | |
--- a/src/gallium/drivers/vc4/vc4_program.c | |
+++ b/src/gallium/drivers/vc4/vc4_program.c | |
@@ -624,7 +624,12 @@ ntq_emit_tex(struct vc4_compile *c, nir_tex_instr *instr) | |
dest[i] = depth_output; | |
} else { | |
for (int i = 0; i < 4; i++) | |
- dest[i] = qir_UNPACK_8_F(c, tex, i); | |
+ if (c->key->tex[unit].format == PIPE_FORMAT_R16G16B16A16_FLOAT) { | |
+ fprintf(stderr, "----> PIPE_FORMAT_R16G16B16A16_FLOAT\n"); | |
+ dest[i] = qir_UNPACK_16_F(c, tex, i); | |
+ } else { | |
+ dest[i] = qir_UNPACK_8_F(c, tex, i); | |
+ } | |
} | |
} | |
@@ -951,12 +956,33 @@ ntq_emit_pack_unorm_4x8(struct vc4_compile *c, nir_alu_instr *instr) | |
continue; | |
} | |
- qir_PACK_8_F(c, result, src, i); | |
+ // TODO(kreeger): Need to figure out if this is a float texture and handle | |
+ // packing as needed- hacking for now: | |
+ qir_PACK_16_F(c, result, src, i); | |
+ /* qir_PACK_8_F(c, result, src, i); */ | |
} | |
ntq_store_dest(c, &instr->dest.dest, 0, qir_MOV(c, result)); | |
} | |
+/** | |
+ * TODO(kreeger): Document me. | |
+ */ | |
+static void | |
+ntq_emit_pack_half_2x16(struct vc4_compile *c, nir_alu_instr *instr) | |
+{ | |
+ // TODO(kreeger): Write me | |
+} | |
+ | |
+/** | |
+ * TODO(kreeger): Document me. | |
+ */ | |
+static void | |
+ntq_emit_unpack_half_2x16(struct vc4_compile *c, nir_alu_instr *instr) | |
+{ | |
+ // TODO(kreeger): Write me | |
+} | |
+ | |
/** Handles sign-extended bitfield extracts for 16 bits. */ | |
static struct qreg | |
ntq_emit_ibfe(struct vc4_compile *c, struct qreg base, struct qreg offset, | |
@@ -1160,6 +1186,11 @@ ntq_emit_alu(struct vc4_compile *c, nir_alu_instr *instr) | |
return; | |
} | |
+ if (instr->op == nir_op_pack_half_2x16) { | |
+ ntq_emit_pack_half_2x16(c, instr); | |
+ return; | |
+ } | |
+ | |
if (instr->op == nir_op_unpack_unorm_4x8) { | |
struct qreg src = ntq_get_src(c, instr->src[0].src, | |
instr->src[0].swizzle[0]); | |
@@ -1171,6 +1202,15 @@ ntq_emit_alu(struct vc4_compile *c, nir_alu_instr *instr) | |
return; | |
} | |
+ if (instr->op == nir_op_unpack_half_2x16) { | |
+ /* struct qreg src = ntq_get_src(c, instr->src[0].src, */ | |
+ /* instr->src[0].swizzle[0]); */ | |
+ ntq_emit_unpack_half_2x16(c, instr); | |
+ // | |
+ // TODO(kreeger): Write me. | |
+ // | |
+ } | |
+ | |
/* General case: We can just grab the one used channel per src. */ | |
struct qreg src[nir_op_infos[instr->op].num_inputs]; | |
for (int i = 0; i < nir_op_infos[instr->op].num_inputs; i++) { | |
@@ -2748,6 +2788,8 @@ vc4_setup_shared_key(struct vc4_context *vc4, struct vc4_key *key, | |
if (!sampler) | |
continue; | |
+ // TODO(kreeger): Assign "is_float_texture" here. | |
+ | |
key->tex[i].format = sampler->format; | |
key->tex[i].swizzle[0] = sampler->swizzle_r; | |
key->tex[i].swizzle[1] = sampler->swizzle_g; | |
@@ -3010,6 +3052,7 @@ vc4_vp_state_bind(struct pipe_context *pctx, void *hwcso) | |
void | |
vc4_program_init(struct pipe_context *pctx) | |
{ | |
+ fprintf(stderr, "vc4_program_init()\n"); | |
struct vc4_context *vc4 = vc4_context(pctx); | |
pctx->create_vs_state = vc4_shader_state_create; | |
diff --git a/src/gallium/drivers/vc4/vc4_qir.c b/src/gallium/drivers/vc4/vc4_qir.c | |
index 71f06aebfa0..793a5671ac8 100644 | |
--- a/src/gallium/drivers/vc4/vc4_qir.c | |
+++ b/src/gallium/drivers/vc4/vc4_qir.c | |
@@ -303,6 +303,9 @@ qir_channels_written(struct qinst *inst) | |
switch (inst->dst.pack) { | |
case QPU_PACK_MUL_NOP: | |
case QPU_PACK_MUL_8888: | |
+ // TODO(kreeger): Guessed values - look? | |
+ case QPU_PACK_MUL_16A: | |
+ case QPU_PACK_MUL_16B: | |
return 0xf; | |
case QPU_PACK_MUL_8A: | |
return 0x1; | |
diff --git a/src/gallium/drivers/vc4/vc4_qir.h b/src/gallium/drivers/vc4/vc4_qir.h | |
index 1aa5f652fbc..fe9b2c4c047 100644 | |
--- a/src/gallium/drivers/vc4/vc4_qir.h | |
+++ b/src/gallium/drivers/vc4/vc4_qir.h | |
@@ -329,6 +329,7 @@ struct vc4_key { | |
struct { | |
enum pipe_format format; | |
uint8_t swizzle[4]; | |
+ uint8_t return_size; // Needed? | |
union { | |
struct { | |
unsigned compare_mode:1; | |
@@ -352,6 +353,7 @@ struct vc4_fs_key { | |
bool stencil_enabled; | |
bool stencil_twoside; | |
bool stencil_full_writemasks; | |
+ bool is_float_render_target; // TODO(kreeger): Use this. | |
bool is_points; | |
bool is_lines; | |
bool point_coord_upper_left; | |
@@ -796,6 +798,14 @@ qir_PACK_8_F(struct vc4_compile *c, struct qreg dest, struct qreg val, int chan) | |
qir_emit_nondef(c, qir_inst(QOP_MMOV, dest, val, c->undef)); | |
} | |
+static inline void | |
+qir_PACK_16_F(struct vc4_compile *c, struct qreg dest, struct qreg val, int chan) | |
+{ | |
+ assert(!dest.pack); | |
+ dest.pack = QPU_PACK_MUL_16A + chan; | |
+ qir_emit_nondef(c, qir_inst(QOP_MMOV, dest, val, c->undef)); | |
+} | |
+ | |
static inline struct qreg | |
qir_PACK_8888_F(struct vc4_compile *c, struct qreg val) | |
{ | |
diff --git a/src/gallium/drivers/vc4/vc4_qpu_defines.h b/src/gallium/drivers/vc4/vc4_qpu_defines.h | |
index e6ca345c3b2..59e5f1cf290 100644 | |
--- a/src/gallium/drivers/vc4/vc4_qpu_defines.h | |
+++ b/src/gallium/drivers/vc4/vc4_qpu_defines.h | |
@@ -189,6 +189,8 @@ enum qpu_pack_mul { | |
QPU_PACK_MUL_8B, | |
QPU_PACK_MUL_8C, | |
QPU_PACK_MUL_8D, | |
+ QPU_PACK_MUL_16A, | |
+ QPU_PACK_MUL_16B, | |
}; | |
enum qpu_pack_a { | |
diff --git a/src/gallium/drivers/vc4/vc4_qpu_disasm.c b/src/gallium/drivers/vc4/vc4_qpu_disasm.c | |
index 9ea26455b73..6fe82cbb4ad 100644 | |
--- a/src/gallium/drivers/vc4/vc4_qpu_disasm.c | |
+++ b/src/gallium/drivers/vc4/vc4_qpu_disasm.c | |
@@ -91,6 +91,8 @@ static const char *qpu_pack_mul[] = { | |
[QPU_PACK_MUL_8B] = ".8b", | |
[QPU_PACK_MUL_8C] = ".8c", | |
[QPU_PACK_MUL_8D] = ".8d", | |
+ [QPU_PACK_MUL_16A] = ".16a", | |
+ [QPU_PACK_MUL_16B] = ".16b", | |
}; | |
/* The QPU unpack for A and R4 files can be described the same, it's just that | |
diff --git a/src/gallium/drivers/vc4/vc4_resource.c b/src/gallium/drivers/vc4/vc4_resource.c | |
index a4d1b903bce..049479487eb 100644 | |
--- a/src/gallium/drivers/vc4/vc4_resource.c | |
+++ b/src/gallium/drivers/vc4/vc4_resource.c | |
@@ -244,6 +244,8 @@ vc4_texture_subdata(struct pipe_context *pctx, | |
struct vc4_resource *rsc = vc4_resource(prsc); | |
struct vc4_resource_slice *slice = &rsc->slices[level]; | |
+ // XXX kreeger Money spot. | |
+ | |
/* For a direct mapping, we can just take the u_transfer path. */ | |
if (!rsc->tiled || | |
box->depth != 1 || | |
diff --git a/src/gallium/drivers/vc4/vc4_screen.c b/src/gallium/drivers/vc4/vc4_screen.c | |
index acb4a1feb0d..49f447560d3 100644 | |
--- a/src/gallium/drivers/vc4/vc4_screen.c | |
+++ b/src/gallium/drivers/vc4/vc4_screen.c | |
@@ -340,6 +340,7 @@ vc4_screen_is_format_supported(struct pipe_screen *pscreen, | |
case PIPE_FORMAT_R32G32B32_SSCALED: | |
case PIPE_FORMAT_R32G32_SSCALED: | |
case PIPE_FORMAT_R32_SSCALED: | |
+ case PIPE_FORMAT_R16G16B16A16_FLOAT: | |
case PIPE_FORMAT_R16G16B16A16_UNORM: | |
case PIPE_FORMAT_R16G16B16_UNORM: | |
case PIPE_FORMAT_R16G16_UNORM: | |
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c | |
index 87c33be7854..f9e1bca3fa5 100644 | |
--- a/src/mesa/main/fbobject.c | |
+++ b/src/mesa/main/fbobject.c | |
@@ -869,16 +869,19 @@ test_attachment_completeness(const struct gl_context *ctx, GLenum format, | |
return; | |
} | |
- /* OES_texture_float allows creation and use of floating point | |
- * textures with GL_FLOAT, GL_HALF_FLOAT but it does not allow | |
- * these textures to be used as a render target, this is done via | |
- * GL_EXT_color_buffer(_half)_float with set of new sized types. | |
- */ | |
- if (_mesa_is_gles(ctx) && (texObj->_IsFloat || texObj->_IsHalfFloat)) { | |
- att_incomplete("bad internal format"); | |
- att->Complete = GL_FALSE; | |
- return; | |
+ if (_mesa_is_gles(ctx)) { | |
+ /** | |
+ * GL ES 2 will allow GL_FLOAT and GL_HALF_FLOAT to render as a | |
+ * target when the appropriate OES_* extensions are available. | |
+ */ | |
+ if ((texObj->_IsHalfFloat && !_mesa_has_OES_texture_half_float(ctx)) || | |
+ (texObj->_IsFloat && !_mesa_has_OES_texture_float(ctx))) { | |
+ att_incomplete("bad internal format"); | |
+ att->Complete = GL_FALSE; | |
+ return; | |
+ } | |
} | |
+ | |
} | |
else if (format == GL_DEPTH) { | |
if (baseFormat == GL_DEPTH_COMPONENT) { | |
diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c | |
index ea72cab5b3e..ed7d0428045 100644 | |
--- a/src/mesa/main/glformats.c | |
+++ b/src/mesa/main/glformats.c | |
@@ -2915,11 +2915,19 @@ _mesa_gles_error_check_format_and_type(const struct gl_context *ctx, | |
case GL_FLOAT: | |
switch (internalFormat) { | |
case GL_RGBA16F: | |
+ if (!_mesa_has_OES_texture_half_float(ctx)) { | |
+ return GL_INVALID_OPERATION; | |
+ } | |
+ break; | |
case GL_RGBA32F: | |
- if (ctx->Version <= 20) | |
+ if (!_mesa_has_OES_texture_float(ctx)) { | |
return GL_INVALID_OPERATION; | |
+ } | |
break; | |
case GL_RGBA: | |
+ // KREEGER - hack here - working around half_float_texture extension: | |
+ if (_mesa_has_OES_texture_half_float(ctx)) | |
+ break; | |
if (_mesa_has_OES_texture_float(ctx) && internalFormat == format) | |
break; | |
default: | |
diff --git a/src/mesa/main/readpix.c b/src/mesa/main/readpix.c | |
index 556c860d393..59f14a65630 100644 | |
--- a/src/mesa/main/readpix.c | |
+++ b/src/mesa/main/readpix.c | |
@@ -1084,7 +1084,8 @@ read_pixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, | |
} else if (ctx->Version < 30) { | |
err = _mesa_es_error_check_format_and_type(ctx, format, type, 2); | |
if (err == GL_NO_ERROR) { | |
- if (type == GL_FLOAT || type == GL_HALF_FLOAT_OES) { | |
+ if ((type == GL_FLOAT || type == GL_HALF_FLOAT_OES) && | |
+ (!_mesa_has_OES_texture_float(ctx) && !_mesa_has_OES_texture_half_float(ctx))) { | |
err = GL_INVALID_OPERATION; | |
} | |
} | |
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c | |
index a43915e18d9..274da519599 100644 | |
--- a/src/mesa/main/teximage.c | |
+++ b/src/mesa/main/teximage.c | |
@@ -845,7 +845,10 @@ _mesa_init_teximage_fields_ms(struct gl_context *ctx, | |
mesa_format format, | |
GLuint numSamples, GLboolean fixedSampleLocations) | |
{ | |
- const GLint base_format =_mesa_base_tex_format(ctx, internalFormat); | |
+ if (1) { | |
+ fprintf(stderr, "intFormat=%s, format=%s\n", _mesa_enum_to_string(internalFormat), _mesa_enum_to_string(format)); | |
+ } | |
+ const GLint base_format = _mesa_base_tex_format(ctx, internalFormat); | |
GLenum target; | |
assert(img); | |
assert(width >= 0); | |
@@ -2844,6 +2847,7 @@ _mesa_choose_texture_format(struct gl_context *ctx, | |
} | |
} | |
+ // TODO(kreeger): Looks like driver not picking right thing! | |
f = ctx->Driver.ChooseTextureFormat(ctx, target, internalFormat, | |
format, type); | |
assert(f != MESA_FORMAT_NONE); | |
diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c | |
index febde1a5e97..01728fd42c3 100644 | |
--- a/src/mesa/state_tracker/st_format.c | |
+++ b/src/mesa/state_tracker/st_format.c | |
@@ -2424,7 +2424,7 @@ st_ChooseTextureFormat(struct gl_context *ctx, GLenum target, | |
mFormat = st_pipe_format_to_mesa_format(pFormat); | |
/* Debugging aid */ | |
- if (0) { | |
+ if (1) { | |
debug_printf("%s(intFormat=%s, format=%s, type=%s) -> %s, %s\n", | |
__func__, | |
_mesa_enum_to_string(internalFormat), |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment