mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-02 05:48:07 +02:00
i915tex: Implement SetTexOffset hook.
Only build tested for I830 generation.
This commit is contained in:
parent
59a08923f5
commit
e0885b84a0
8 changed files with 103 additions and 28 deletions
|
|
@ -575,6 +575,7 @@
|
|||
#define MT_16BIT_DIB_RGB565_8888 (7<<3)
|
||||
#define MT_32BIT_ARGB8888 (0<<3) /* SURFACE_32BIT */
|
||||
#define MT_32BIT_ABGR8888 (1<<3)
|
||||
#define MT_32BIT_XRGB8888 (2<<3) /* XXX: Guess from i915_reg.h */
|
||||
#define MT_32BIT_BUMP_XLDVDU_8888 (6<<3)
|
||||
#define MT_32BIT_DIB_8888 (7<<3)
|
||||
#define MT_411_YUV411 (0<<3) /* SURFACE_411 */
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
|
|||
struct gl_texture_object *tObj = ctx->Texture.Unit[unit]._Current;
|
||||
struct intel_texture_object *intelObj = intel_texture_object(tObj);
|
||||
struct gl_texture_image *firstImage;
|
||||
GLuint *state = i830->state.Tex[unit];
|
||||
GLuint *state = i830->state.Tex[unit], format, pitch;
|
||||
|
||||
memset(state, 0, sizeof(state));
|
||||
|
||||
|
|
@ -128,7 +128,7 @@ i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
|
|||
i830->state.tex_buffer[unit] = NULL;
|
||||
}
|
||||
|
||||
if (!intel_finalize_mipmap_tree(intel, unit))
|
||||
if (!intelObj->imageOverride && !intel_finalize_mipmap_tree(intel, unit))
|
||||
return GL_FALSE;
|
||||
|
||||
/* Get first image here, since intelObj->firstLevel will get set in
|
||||
|
|
@ -136,11 +136,34 @@ i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
|
|||
*/
|
||||
firstImage = tObj->Image[0][intelObj->firstLevel];
|
||||
|
||||
i830->state.tex_buffer[unit] = driBOReference(intelObj->mt->region->buffer);
|
||||
i830->state.tex_offset[unit] = intel_miptree_image_offset(intelObj->mt, 0,
|
||||
intelObj->
|
||||
firstLevel);
|
||||
if (intelObj->imageOverride) {
|
||||
i830->state.tex_buffer[unit] = NULL;
|
||||
i830->state.tex_offset[unit] = intelObj->textureOffset;
|
||||
|
||||
switch (intelObj->depthOverride) {
|
||||
case 32:
|
||||
format = MAPSURF_32BIT | MT_32BIT_ARGB8888;
|
||||
break;
|
||||
case 24:
|
||||
default:
|
||||
format = MAPSURF_32BIT | MT_32BIT_XRGB8888;
|
||||
break;
|
||||
case 16:
|
||||
format = MAPSURF_16BIT | MT_16BIT_RGB565;
|
||||
break;
|
||||
}
|
||||
|
||||
pitch = intelObj->pitchOverride;
|
||||
} else {
|
||||
i830->state.tex_buffer[unit] = driBOReference(intelObj->mt->region->
|
||||
buffer);
|
||||
i830->state.tex_offset[unit] = intel_miptree_image_offset(intelObj->mt,
|
||||
0, intelObj->
|
||||
firstLevel);
|
||||
|
||||
format = translate_texture_format(firstImage->TexFormat->MesaFormat);
|
||||
pitch = intelObj->mt->pitch * intelObj->mt->cpp;
|
||||
}
|
||||
|
||||
state[I830_TEXREG_TM0LI] = (_3DSTATE_LOAD_STATE_IMMEDIATE_2 |
|
||||
(LOAD_TEXTURE_MAP0 << unit) | 4);
|
||||
|
|
@ -151,12 +174,10 @@ i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
|
|||
|
||||
state[I830_TEXREG_TM0S1] =
|
||||
(((firstImage->Height - 1) << TM0S1_HEIGHT_SHIFT) |
|
||||
((firstImage->Width - 1) << TM0S1_WIDTH_SHIFT) |
|
||||
translate_texture_format(firstImage->TexFormat->MesaFormat));
|
||||
((firstImage->Width - 1) << TM0S1_WIDTH_SHIFT) | format);
|
||||
|
||||
state[I830_TEXREG_TM0S2] =
|
||||
(((((intelObj->mt->pitch * intelObj->mt->cpp) / 4) -
|
||||
1) << TM0S2_PITCH_SHIFT) | TM0S2_CUBE_FACE_ENA_MASK);
|
||||
((((pitch / 4) - 1) << TM0S2_PITCH_SHIFT) | TM0S2_CUBE_FACE_ENA_MASK);
|
||||
|
||||
{
|
||||
if (tObj->Target == GL_TEXTURE_CUBE_MAP)
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
|
|||
struct gl_texture_object *tObj = ctx->Texture.Unit[unit]._Current;
|
||||
struct intel_texture_object *intelObj = intel_texture_object(tObj);
|
||||
struct gl_texture_image *firstImage;
|
||||
GLuint *state = i915->state.Tex[unit];
|
||||
GLuint *state = i915->state.Tex[unit], format, pitch;
|
||||
|
||||
memset(state, 0, sizeof(state));
|
||||
|
||||
|
|
@ -133,7 +133,7 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
|
|||
i915->state.tex_buffer[unit] = NULL;
|
||||
}
|
||||
|
||||
if (!intel_finalize_mipmap_tree(intel, unit))
|
||||
if (!intelObj->imageOverride && !intel_finalize_mipmap_tree(intel, unit))
|
||||
return GL_FALSE;
|
||||
|
||||
/* Get first image here, since intelObj->firstLevel will get set in
|
||||
|
|
@ -141,24 +141,45 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
|
|||
*/
|
||||
firstImage = tObj->Image[0][intelObj->firstLevel];
|
||||
|
||||
i915->state.tex_buffer[unit] = driBOReference(intelObj->mt->region->buffer);
|
||||
i915->state.tex_offset[unit] = intel_miptree_image_offset(intelObj->mt, 0,
|
||||
intelObj->
|
||||
firstLevel);
|
||||
if (intelObj->imageOverride) {
|
||||
i915->state.tex_buffer[unit] = NULL;
|
||||
i915->state.tex_offset[unit] = intelObj->textureOffset;
|
||||
|
||||
switch (intelObj->depthOverride) {
|
||||
case 32:
|
||||
format = MAPSURF_32BIT | MT_32BIT_ARGB8888;
|
||||
break;
|
||||
case 24:
|
||||
default:
|
||||
format = MAPSURF_32BIT | MT_32BIT_XRGB8888;
|
||||
break;
|
||||
case 16:
|
||||
format = MAPSURF_16BIT | MT_16BIT_RGB565;
|
||||
break;
|
||||
}
|
||||
|
||||
pitch = intelObj->pitchOverride;
|
||||
} else {
|
||||
i915->state.tex_buffer[unit] = driBOReference(intelObj->mt->region->
|
||||
buffer);
|
||||
i915->state.tex_offset[unit] = intel_miptree_image_offset(intelObj->mt,
|
||||
0, intelObj->
|
||||
firstLevel);
|
||||
|
||||
format = translate_texture_format(firstImage->TexFormat->MesaFormat);
|
||||
pitch = intelObj->mt->pitch * intelObj->mt->cpp;
|
||||
}
|
||||
|
||||
state[I915_TEXREG_MS3] =
|
||||
(((firstImage->Height - 1) << MS3_HEIGHT_SHIFT) |
|
||||
((firstImage->Width - 1) << MS3_WIDTH_SHIFT) |
|
||||
translate_texture_format(firstImage->TexFormat->MesaFormat) |
|
||||
((firstImage->Width - 1) << MS3_WIDTH_SHIFT) | format |
|
||||
MS3_USE_FENCE_REGS);
|
||||
|
||||
state[I915_TEXREG_MS4] =
|
||||
(((((intelObj->mt->pitch * intelObj->mt->cpp) / 4) -
|
||||
1) << MS4_PITCH_SHIFT) | MS4_CUBE_FACE_ENA_MASK |
|
||||
((((intelObj->lastLevel -
|
||||
intelObj->firstLevel) *
|
||||
4)) << MS4_MAX_LOD_SHIFT) | ((firstImage->Depth -
|
||||
1) << MS4_VOLUME_DEPTH_SHIFT));
|
||||
((((pitch / 4) - 1) << MS4_PITCH_SHIFT) | MS4_CUBE_FACE_ENA_MASK |
|
||||
((((intelObj->lastLevel - intelObj->firstLevel) * 4)) <<
|
||||
MS4_MAX_LOD_SHIFT) | ((firstImage->Depth - 1) <<
|
||||
MS4_VOLUME_DEPTH_SHIFT));
|
||||
|
||||
|
||||
{
|
||||
|
|
|
|||
|
|
@ -381,11 +381,13 @@ i915_emit_state(struct intel_context *intel)
|
|||
DRM_BO_MASK_MEM | DRM_BO_FLAG_READ,
|
||||
state->tex_offset[i]);
|
||||
}
|
||||
else {
|
||||
else if (state == &i915->meta) {
|
||||
assert(i == 0);
|
||||
assert(state == &i915->meta);
|
||||
OUT_BATCH(0);
|
||||
}
|
||||
else {
|
||||
OUT_BATCH(state->tex_offset[i]);
|
||||
}
|
||||
|
||||
OUT_BATCH(state->Tex[i][I915_TEXREG_MS3]);
|
||||
OUT_BATCH(state->Tex[i][I915_TEXREG_MS4]);
|
||||
|
|
|
|||
|
|
@ -92,6 +92,10 @@ struct intel_texture_object
|
|||
* regions will be copied to this region and the old storage freed.
|
||||
*/
|
||||
struct intel_mipmap_tree *mt;
|
||||
|
||||
GLboolean imageOverride;
|
||||
GLint depthOverride;
|
||||
GLuint pitchOverride;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -776,7 +776,8 @@ static const struct __DriverAPIRec intelAPI = {
|
|||
.WaitForMSC = driWaitForMSC32,
|
||||
.WaitForSBC = NULL,
|
||||
.SwapBuffersMSC = NULL,
|
||||
.CopySubBuffer = intelCopySubBuffer
|
||||
.CopySubBuffer = intelCopySubBuffer,
|
||||
.setTexOffset = intelSetTexOffset,
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -135,6 +135,9 @@ void intelGetCompressedTexImage(GLcontext *ctx, GLenum target, GLint level,
|
|||
const struct gl_texture_object *texObj,
|
||||
const struct gl_texture_image *texImage);
|
||||
|
||||
void intelSetTexOffset(__DRIcontext *pDRICtx, GLint texname,
|
||||
unsigned long long offset, GLint depth, GLuint pitch);
|
||||
|
||||
GLuint intel_finalize_mipmap_tree(struct intel_context *intel, GLuint unit);
|
||||
|
||||
void intel_tex_map_images(struct intel_context *intel,
|
||||
|
|
|
|||
|
|
@ -378,6 +378,9 @@ intelTexImage(GLcontext * ctx,
|
|||
assert(!intelObj->mt);
|
||||
}
|
||||
|
||||
if (!pixels)
|
||||
return;
|
||||
|
||||
if (!intelObj->mt) {
|
||||
guess_and_alloc_mipmap_tree(intel, intelObj, intelImage);
|
||||
if (!intelObj->mt) {
|
||||
|
|
@ -385,7 +388,6 @@ intelTexImage(GLcontext * ctx,
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
assert(!intelImage->mt);
|
||||
|
||||
if (intelObj->mt &&
|
||||
|
|
@ -667,3 +669,23 @@ intelGetCompressedTexImage(GLcontext *ctx, GLenum target, GLint level,
|
|||
texObj, texImage, 1);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
intelSetTexOffset(__DRIcontext *pDRICtx, GLint texname,
|
||||
unsigned long long offset, GLint depth, GLuint pitch)
|
||||
{
|
||||
struct intel_context *intel = (struct intel_context*)
|
||||
((__DRIcontextPrivate*)pDRICtx->private)->driverPrivate;
|
||||
struct gl_texture_object *tObj = _mesa_lookup_texture(&intel->ctx, texname);
|
||||
struct intel_texture_object *intelObj = intel_texture_object(tObj);
|
||||
|
||||
if (!intelObj)
|
||||
return;
|
||||
|
||||
intelObj->imageOverride = GL_TRUE;
|
||||
intelObj->depthOverride = depth;
|
||||
intelObj->pitchOverride = pitch;
|
||||
|
||||
if (offset)
|
||||
intelObj->textureOffset = offset;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue