Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial RGBA16F capabilities for vc4 #115

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/egl/drivers/dri2/platform_drm.c
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,7 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp)

dri2_dpy->gbm_dri = gbm_dri_device(gbm);
dri2_dpy->driver_name = strdup(dri2_dpy->gbm_dri->driver_name);
fprintf(stderr, "$$$ DRIVER_NAME: %s\n", dri2_dpy->gbm_dri->driver_name);

dri2_dpy->dri_screen = dri2_dpy->gbm_dri->screen;
dri2_dpy->core = dri2_dpy->gbm_dri->core;
Expand Down Expand Up @@ -787,6 +788,7 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp)
*/
dri2_dpy->vtbl = &dri2_drm_display_vtbl;

fprintf(stderr, "---> EGL_TRUE\n");
return EGL_TRUE;

cleanup:
Expand Down
4 changes: 3 additions & 1 deletion src/gallium/drivers/vc4/kernel/vc4_validate.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 7 additions & 1 deletion src/gallium/drivers/vc4/vc4_formats.c
Original file line number Diff line number Diff line change
Expand Up @@ -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_*. */
Expand All @@ -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) { \
Expand Down Expand Up @@ -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 *
Expand Down
29 changes: 28 additions & 1 deletion src/gallium/drivers/vc4/vc4_program.c
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,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) {
// TODO(kreeger) - unpack 8 or 16 as needed!
/* dest[i] = qir_UNPACK_8_F(c, tex, i); */
} else {
dest[i] = qir_UNPACK_8_F(c, tex, i);
}
}
}

Expand Down Expand Up @@ -939,6 +944,15 @@ ntq_emit_pack_unorm_4x8(struct vc4_compile *c, nir_alu_instr *instr)
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
}

/** Handles sign-extended bitfield extracts for 16 bits. */
static struct qreg
ntq_emit_ibfe(struct vc4_compile *c, struct qreg base, struct qreg offset,
Expand Down Expand Up @@ -1142,6 +1156,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]);
Expand All @@ -1153,6 +1172,12 @@ ntq_emit_alu(struct vc4_compile *c, nir_alu_instr *instr)
return;
}

if (instr->op == nir_op_unpack_half_2x16) {
//
// 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++) {
Expand Down Expand Up @@ -2722,6 +2747,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;
Expand Down
2 changes: 2 additions & 0 deletions src/gallium/drivers/vc4/vc4_qir.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/gallium/drivers/vc4/vc4_screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,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:
Expand Down
4 changes: 4 additions & 0 deletions src/glx/dri2.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,11 @@ DRI2Connect(Display * dpy, XID window, char **driverName, char **deviceName)
return False;
}

fprintf(stderr, "rep.length: %lu\n", rep.length);
fprintf(stderr, "rep.type: %x\n", rep.type);

if (rep.driverNameLength == 0 && rep.deviceNameLength == 0) {
fprintf(stderr, "Bad driver info...\n");
UnlockDisplay(dpy);
SyncHandle();
return False;
Expand Down
8 changes: 8 additions & 0 deletions src/glx/dri2_glx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1219,10 +1219,16 @@ dri2CreateScreen(int screen, struct glx_display * priv)
return NULL;
}

fprintf(stderr, "dri2CreateDrawable: %d\n", screen);

if (!DRI2Connect(priv->dpy, RootWindow(priv->dpy, screen),
&driverName, &deviceName)) {
glx_screen_cleanup(&psc->base);
free(psc);

fprintf(stderr, "deviceName: %s\n", deviceName);
fprintf(stderr, "driverName: %s\n", driverName);
/* InfoMessageF("---> DRIVER: %n\n", deviceName); */
InfoMessageF("screen %d does not appear to be DRI2 capable\n", screen);
return NULL;
}
Expand Down Expand Up @@ -1435,6 +1441,8 @@ dri2CreateDisplay(Display * dpy)
pdp->base.destroyDisplay = dri2DestroyDisplay;
pdp->base.createScreen = dri2CreateScreen;

fprintf(stderr, "dri2CreateDisplay()\n");

i = 0;
if (pdp->driMinor < 1)
pdp->loader_extensions[i++] = &dri2LoaderExtension_old.base;
Expand Down
2 changes: 2 additions & 0 deletions src/glx/dri_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ dri_message(int level, const char *f, ...)
_X_HIDDEN void *
driOpenDriver(const char *driverName)
{
fprintf(stderr, "---> driOpenDriver(): %s\n", driverName);

void *glhandle, *handle;
const char *libPaths, *p, *next;
char realDriverName[200];
Expand Down
12 changes: 9 additions & 3 deletions src/glx/glxext.c
Original file line number Diff line number Diff line change
Expand Up @@ -819,19 +819,25 @@ AllocAndFetchScreenConfigs(Display * dpy, struct glx_display * priv)
if (priv->dri3Display)
psc = (*priv->dri3Display->createScreen) (i, priv);
#endif /* HAVE_DRI3 */
if (psc == NULL && priv->dri2Display)
if (psc == NULL && priv->dri2Display) {
psc = (*priv->dri2Display->createScreen) (i, priv);
if (psc == NULL && priv->driDisplay)
fprintf(stderr, "... checking dri2Display\n");
}
if (psc == NULL && priv->driDisplay) {
fprintf(stderr, "... checking driDisplay\n");
psc = (*priv->driDisplay->createScreen) (i, priv);
}
#endif /* GLX_USE_DRM */

#ifdef GLX_USE_WINDOWSGL
if (psc == NULL && priv->windowsdriDisplay)
psc = (*priv->windowsdriDisplay->createScreen) (i, priv);
#endif

if (psc == NULL && priv->driswDisplay)
if (psc == NULL && priv->driswDisplay) {
fprintf(stderr, "... checking driswDisplay\n");
psc = (*priv->driswDisplay->createScreen) (i, priv);
}
#endif /* GLX_DIRECT_RENDERING && !GLX_USE_APPLEGL */

#if defined(GLX_USE_APPLEGL)
Expand Down
1 change: 1 addition & 0 deletions src/mesa/drivers/dri/swrast/swrast.c
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,7 @@ get_string(struct gl_context *ctx, GLenum pname)
case GL_VENDOR:
return (const GLubyte *) swrast_vendor_string;
case GL_RENDERER:
fprintf(stderr, "$$ HAHA getting string from swrast driver\n");
return (const GLubyte *) swrast_renderer_string;
default:
return NULL;
Expand Down