return MESA_FORMAT_ARGB8888;
case GL_RGB5_A1:
return MESA_FORMAT_ARGB1555;
- case GL_RGBA2:
- case GL_RGBA4:
- return MESA_FORMAT_ARGB4444;
case 3:
case GL_R3_G3_B2:
{
struct nouveau_surface *s = &to_nouveau_texture(t)->surfaces[level];
- return s->bo && s->width == ti->Width &&
- s->height == ti->Height &&
- s->format == ti->TexFormat;
+ return t->Target == GL_TEXTURE_RECTANGLE ||
+ (s->bo && s->width == ti->Width &&
+ s->height == ti->Height &&
+ s->format == ti->TexFormat);
}
static GLboolean
struct nouveau_surface *ss = to_nouveau_texture(t)->surfaces;
struct nouveau_surface *s = &to_nouveau_teximage(ti)->surface;
- context_drv(ctx)->surface_copy(ctx, &ss[level], s,
- x, y, x, y,
- width, height);
+ if (t->Target == GL_TEXTURE_RECTANGLE)
+ nouveau_surface_ref(s, &ss[level]);
+ else
+ context_drv(ctx)->surface_copy(ctx, &ss[level], s,
+ x, y, x, y,
+ width, height);
return GL_TRUE;
}
{
struct gl_texture_image *base = t->Image[0][t->BaseLevel];
- if (base) {
+ if (base && t->Target != GL_TEXTURE_RECTANGLE) {
struct nouveau_surface *ss = to_nouveau_texture(t)->surfaces;
struct nouveau_surface *s = &to_nouveau_teximage(base)->surface;
int i, ret, last = get_last_level(t);
#include "nv04_driver.h"
#include "nv10_driver.h"
+static const struct dri_extension nv10_extensions[] = {
+ { "GL_EXT_texture_rectangle", NULL },
+ { NULL, NULL }
+};
+
static void
nv10_clear(GLcontext *ctx, GLbitfield buffers)
{
if (!nouveau_context_init(ctx, screen, visual, share_ctx))
goto fail;
+ driInitExtensions(ctx, nv10_extensions, GL_FALSE);
+
/* GL constants. */
ctx->Const.MaxTextureLevels = 12;
ctx->Const.MaxTextureCoordUnits = NV10_TEXTURE_UNITS;
}
static uint32_t
-get_tex_format(struct gl_texture_image *ti)
+get_tex_format_pot(struct gl_texture_image *ti)
{
switch (ti->TexFormat) {
case MESA_FORMAT_ARGB8888:
}
}
+static uint32_t
+get_tex_format_rect(struct gl_texture_image *ti)
+{
+ switch (ti->TexFormat) {
+ case MESA_FORMAT_ARGB1555:
+ return NV10TCL_TX_FORMAT_FORMAT_A1R5G5B5_RECT;
+
+ case MESA_FORMAT_RGB565:
+ return NV10TCL_TX_FORMAT_FORMAT_R5G6B5_RECT;
+
+ case MESA_FORMAT_ARGB8888:
+ return NV10TCL_TX_FORMAT_FORMAT_A8R8G8B8_RECT;
+
+ case MESA_FORMAT_A8:
+ case MESA_FORMAT_L8:
+ case MESA_FORMAT_I8:
+ return NV10TCL_TX_FORMAT_FORMAT_A8_RECT;
+
+ default:
+ assert(0);
+ }
+}
+
void
nv10_emit_tex_obj(GLcontext *ctx, int emit)
{
| nvgl_wrap_mode(t->WrapS) << 24
| ti->HeightLog2 << 20
| ti->WidthLog2 << 16
- | get_tex_format(ti)
| 5 << 4 | 1 << 12;
tx_filter = nvgl_filter_mode(t->MagFilter) << 28
tx_enable = NV10TCL_TX_ENABLE_ENABLE
| log2i(t->MaxAnisotropy) << 4;
+ if (t->Target == GL_TEXTURE_RECTANGLE) {
+ BEGIN_RING(chan, celsius, NV10TCL_TX_NPOT_PITCH(i), 1);
+ OUT_RING(chan, s->pitch << 16);
+ BEGIN_RING(chan, celsius, NV10TCL_TX_NPOT_SIZE(i), 1);
+ OUT_RING(chan, align(s->width, 2) << 16 | s->height);
+
+ tx_format |= get_tex_format_rect(ti);
+ } else {
+ tx_format |= get_tex_format_pot(ti);
+ }
+
if (t->MinFilter != GL_NEAREST &&
t->MinFilter != GL_LINEAR) {
int lod_min = t->MinLod;
#include "nv10_driver.h"
#include "nv20_driver.h"
+static const struct dri_extension nv20_extensions[] = {
+ { "GL_EXT_texture_rectangle", NULL },
+ { NULL, NULL }
+};
+
static void
nv20_hwctx_init(GLcontext *ctx)
{
if (!nouveau_context_init(ctx, screen, visual, share_ctx))
goto fail;
+ driInitExtensions(ctx, nv20_extensions, GL_FALSE);
+
/* GL constants. */
ctx->Const.MaxTextureCoordUnits = NV20_TEXTURE_UNITS;
ctx->Const.MaxTextureImageUnits = NV20_TEXTURE_UNITS;
#include "nv20_driver.h"
static uint32_t
-get_tex_format(struct gl_texture_image *ti)
+get_tex_format_pot(struct gl_texture_image *ti)
{
switch (ti->TexFormat) {
case MESA_FORMAT_ARGB8888:
}
}
+static uint32_t
+get_tex_format_rect(struct gl_texture_image *ti)
+{
+ switch (ti->TexFormat) {
+ case MESA_FORMAT_ARGB1555:
+ return NV20TCL_TX_FORMAT_FORMAT_A1R5G5B5_RECT;
+
+ case MESA_FORMAT_RGB565:
+ return NV20TCL_TX_FORMAT_FORMAT_R5G6B5_RECT;
+
+ case MESA_FORMAT_ARGB8888:
+ return NV20TCL_TX_FORMAT_FORMAT_A8R8G8B8_RECT;
+
+ case MESA_FORMAT_L8:
+ return NV20TCL_TX_FORMAT_FORMAT_L8_RECT;
+
+ case MESA_FORMAT_A8:
+ case MESA_FORMAT_I8:
+ return NV20TCL_TX_FORMAT_FORMAT_A8_RECT;
+
+ case MESA_FORMAT_ARGB4444:
+ return NV20TCL_TX_FORMAT_FORMAT_A4R4G4B4_RECT;
+
+ default:
+ assert(0);
+ }
+}
+
void
nv20_emit_tex_obj(GLcontext *ctx, int emit)
{
tx_format = ti->DepthLog2 << 28
| ti->HeightLog2 << 24
| ti->WidthLog2 << 20
- | get_tex_format(ti)
| NV20TCL_TX_FORMAT_DIMS_2D
| NV20TCL_TX_FORMAT_NO_BORDER
| 1 << 16;
tx_enable = NV20TCL_TX_ENABLE_ENABLE
| log2i(t->MaxAnisotropy) << 4;
+ if (t->Target == GL_TEXTURE_RECTANGLE) {
+ BEGIN_RING(chan, kelvin, NV20TCL_TX_NPOT_PITCH(i), 1);
+ OUT_RING(chan, s->pitch << 16);
+ BEGIN_RING(chan, kelvin, NV20TCL_TX_NPOT_SIZE(i), 1);
+ OUT_RING(chan, s->width << 16 | s->height);
+
+ tx_format |= get_tex_format_rect(ti);
+ } else {
+ tx_format |= get_tex_format_pot(ti);
+ }
+
if (t->MinFilter != GL_NEAREST &&
t->MinFilter != GL_LINEAR) {
int lod_min = t->MinLod;