drm_intel_bo_reference(intelObj->mt->region->bo);
i830->state.tex_buffer[unit] = intelObj->mt->region->bo;
- pitch = intelObj->mt->region->pitch * intelObj->mt->cpp;
+ pitch = intelObj->mt->region->pitch;
/* XXX: This calculation is probably broken for tiled images with
* a non-page-aligned offset.
struct intel_texture_object *intelObj = intel_texture_object(tObj);
struct gl_texture_image *firstImage;
struct gl_sampler_object *sampler = _mesa_get_samplerobj(ctx, unit);
- GLuint *state = i915->state.Tex[unit], format, pitch;
+ GLuint *state = i915->state.Tex[unit], format;
GLint lodbias, aniso = 0;
GLubyte border[4];
GLfloat maxlod;
format = translate_texture_format(firstImage->TexFormat,
tObj->DepthMode);
- pitch = intelObj->mt->region->pitch * intelObj->mt->cpp;
state[I915_TEXREG_MS3] =
(((firstImage->Height - 1) << MS3_HEIGHT_SHIFT) |
*/
maxlod = MIN2(sampler->MaxLod, tObj->_MaxLevel - tObj->BaseLevel);
state[I915_TEXREG_MS4] =
- ((((pitch / 4) - 1) << MS4_PITCH_SHIFT) |
+ ((((intelObj->mt->region->pitch / 4) - 1) << MS4_PITCH_SHIFT) |
MS4_CUBE_FACE_ENA_MASK |
(U_FIXED(CLAMP(maxlod, 0.0, 11.0), 2) << MS4_MAX_LOD_SHIFT) |
((firstImage->Depth - 1) << MS4_VOLUME_DEPTH_SHIFT));
state[1] = buffer_id;
if (region != NULL) {
- state[1] |= BUF_3D_PITCH(region->pitch * region->cpp);
+ state[1] |= BUF_3D_PITCH(region->pitch);
if (region->tiling != I915_TILING_NONE) {
state[1] |= BUF_3D_TILED_SURFACE;
BEGIN_BATCH(len);
OUT_BATCH(_3DSTATE_DEPTH_BUFFER << 16 | (len - 2));
- OUT_BATCH(((region->pitch * region->cpp) - 1) |
+ OUT_BATCH((region->pitch - 1) |
(brw_depthbuffer_format(brw) << 18) |
((hiz_mt ? 1 : 0) << 21) | /* separate stencil enable */
((hiz_mt ? 1 : 0) << 22) | /* hiz enable */
if (hiz_mt) {
BEGIN_BATCH(3);
OUT_BATCH((_3DSTATE_HIER_DEPTH_BUFFER << 16) | (3 - 2));
- OUT_BATCH(hiz_mt->region->pitch * hiz_mt->region->cpp - 1);
+ OUT_BATCH(hiz_mt->region->pitch - 1);
OUT_RELOC(hiz_mt->region->bo,
I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
brw->depthstencil.hiz_offset);
* The pitch must be set to 2x the value computed based on width, as
* the stencil buffer is stored with two rows interleaved.
*/
- OUT_BATCH(2 * region->pitch * region->cpp - 1);
+ OUT_BATCH(2 * region->pitch - 1);
OUT_RELOC(region->bo,
I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
brw->depthstencil.stencil_offset);
surf[3] = (brw_get_surface_tiling_bits(intelObj->mt->region->tiling) |
(depth - 1) << BRW_SURFACE_DEPTH_SHIFT |
- ((intelObj->mt->region->pitch * intelObj->mt->cpp) - 1) <<
+ (intelObj->mt->region->pitch - 1) <<
BRW_SURFACE_PITCH_SHIFT);
surf[4] = 0;
(rb->Height - 1) << BRW_SURFACE_HEIGHT_SHIFT);
surf[3] = (brw_get_surface_tiling_bits(region->tiling) |
- ((region->pitch * region->cpp) - 1) << BRW_SURFACE_PITCH_SHIFT);
+ (region->pitch - 1) << BRW_SURFACE_PITCH_SHIFT);
surf[4] = brw_get_surface_num_multisamples(mt->num_samples);
uint32_t tiling = surface->map_stencil_as_y_tiled
? BRW_SURFACE_TILED | BRW_SURFACE_TILED_Y
: brw_get_surface_tiling_bits(region->tiling);
- uint32_t pitch_bytes = region->pitch * region->cpp;
+ uint32_t pitch_bytes = region->pitch;
if (surface->map_stencil_as_y_tiled)
pitch_bytes *= 2;
surf[3] = (tiling |
BEGIN_BATCH(7);
OUT_BATCH(_3DSTATE_DEPTH_BUFFER << 16 | (7 - 2));
- uint32_t pitch_bytes =
- params->depth.mt->region->pitch * params->depth.mt->region->cpp;
- OUT_BATCH((pitch_bytes - 1) |
+ OUT_BATCH((params->depth.mt->region->pitch - 1) |
params->depth_format << 18 |
1 << 21 | /* separate stencil enable */
1 << 22 | /* hiz enable */
BEGIN_BATCH(3);
OUT_BATCH((_3DSTATE_HIER_DEPTH_BUFFER << 16) | (3 - 2));
- OUT_BATCH(hiz_region->pitch * hiz_region->cpp - 1);
+ OUT_BATCH(hiz_region->pitch - 1);
OUT_RELOC(hiz_region->bo,
I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
hiz_offset);
surf[2] = SET_FIELD(width - 1, GEN7_SURFACE_WIDTH) |
SET_FIELD(height - 1, GEN7_SURFACE_HEIGHT);
- uint32_t pitch_bytes = region->pitch * region->cpp;
+ uint32_t pitch_bytes = region->pitch;
if (surface->map_stencil_as_y_tiled)
pitch_bytes *= 2;
surf[3] = pitch_bytes - 1;
BEGIN_BATCH(7);
OUT_BATCH(GEN7_3DSTATE_DEPTH_BUFFER << 16 | (7 - 2));
- uint32_t pitch_bytes =
- params->depth.mt->region->pitch * params->depth.mt->region->cpp;
- OUT_BATCH((pitch_bytes - 1) |
+ OUT_BATCH((params->depth.mt->region->pitch - 1) |
params->depth_format << 18 |
1 << 22 | /* hiz enable */
1 << 28 | /* depth write */
BEGIN_BATCH(3);
OUT_BATCH((GEN7_3DSTATE_HIER_DEPTH_BUFFER << 16) | (3 - 2));
- OUT_BATCH(hiz_region->pitch * hiz_region->cpp - 1);
+ OUT_BATCH(hiz_region->pitch - 1);
OUT_RELOC(hiz_region->bo,
I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
hiz_offset);
/* _NEW_DEPTH, _NEW_STENCIL */
BEGIN_BATCH(7);
OUT_BATCH(GEN7_3DSTATE_DEPTH_BUFFER << 16 | (7 - 2));
- OUT_BATCH(((region->pitch * region->cpp) - 1) |
+ OUT_BATCH((region->pitch - 1) |
(brw_depthbuffer_format(brw) << 18) |
((hiz_mt ? 1 : 0) << 22) | /* hiz enable */
((stencil_mt != NULL && ctx->Stencil.WriteMask != 0) << 27) |
} else {
BEGIN_BATCH(3);
OUT_BATCH(GEN7_3DSTATE_HIER_DEPTH_BUFFER << 16 | (3 - 2));
- OUT_BATCH(hiz_mt->region->pitch * hiz_mt->region->cpp - 1);
+ OUT_BATCH(hiz_mt->region->pitch - 1);
OUT_RELOC(hiz_mt->region->bo,
I915_GEM_DOMAIN_RENDER,
I915_GEM_DOMAIN_RENDER,
* indicate that it does.
*/
OUT_BATCH(enabled |
- (2 * stencil_mt->region->pitch * stencil_mt->region->cpp - 1));
+ (2 * stencil_mt->region->pitch - 1));
OUT_RELOC(stencil_mt->region->bo,
I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
brw->depthstencil.stencil_offset);
/* Compute the pitch in units of tiles. To do this we need to divide the
* pitch in bytes by 128, since a single Y-tile is 128 bytes wide.
*/
- unsigned pitch_bytes = mcs_mt->region->pitch * mcs_mt->cpp;
- unsigned pitch_tiles = pitch_bytes / 128;
+ unsigned pitch_tiles = mcs_mt->region->pitch / 128;
/* The upper 20 bits of surface state DWORD 6 are the upper 20 bits of the
* GPU address of the MCS buffer; the lower 12 bits contain other control
surf[2] = SET_FIELD(width - 1, GEN7_SURFACE_WIDTH) |
SET_FIELD(height - 1, GEN7_SURFACE_HEIGHT);
surf[3] = SET_FIELD(depth - 1, BRW_SURFACE_DEPTH) |
- ((intelObj->mt->region->pitch * intelObj->mt->cpp) - 1);
+ ((intelObj->mt->region->pitch) - 1);
surf[5] = intelObj->_MaxLevel - tObj->BaseLevel; /* mip count */
surf[2] = SET_FIELD(rb->Width - 1, GEN7_SURFACE_WIDTH) |
SET_FIELD(rb->Height - 1, GEN7_SURFACE_HEIGHT);
- surf[3] = (region->pitch * region->cpp) - 1;
+ surf[3] = region->pitch - 1;
surf[4] = gen7_surface_msaa_bits(irb->mt->num_samples, irb->mt->msaa_layout);
DBG("%s dst:buf(%p)/%d %d,%d sz:%dx%d\n",
__FUNCTION__,
- region->bo, (pitch * cpp),
+ region->bo, pitch,
x1, y1, x2 - x1, y2 - y1);
BR13 = 0xf0 << 16;
pitch /= 4;
}
#endif
- BR13 |= (pitch * cpp);
+ BR13 |= pitch;
if (is_depth_stencil) {
clear_val = clear_depth_value;
DBG("%s dst:buf(%p)/%d %d,%d sz:%dx%d\n",
__FUNCTION__,
- intel_image->mt->region->bo, (pitch * cpp),
+ intel_image->mt->region->bo, pitch,
x1, y1, x2 - x1, y2 - y1);
BR13 = br13_for_cpp(cpp) | 0xf0 << 16;
pitch /= 4;
}
#endif
- BR13 |= (pitch * cpp);
+ BR13 |= pitch;
/* do space check before going any further */
aper_array[0] = intel->batch.bo;
buffer->cpp,
drawable->w,
drawable->h,
- buffer->pitch / buffer->cpp,
+ buffer->pitch,
buffer->name,
buffer_name);
if (!region)
DBG("validate blit mt %s %p %d,%d/%d -> mt %s %p %d,%d/%d (%dx%d)\n",
_mesa_get_format_name(src_mt->format),
- src_mt, src_x, src_y, src_mt->region->pitch * src_mt->region->cpp,
+ src_mt, src_x, src_y, src_mt->region->pitch,
_mesa_get_format_name(dst_mt->format),
- dst_mt, dst_x, dst_y, dst_mt->region->pitch * dst_mt->region->cpp,
+ dst_mt, dst_x, dst_y, dst_mt->region->pitch,
width, height);
if (!intelEmitCopyBlit(intel,
dst_mt->region->cpp,
- src_mt->region->pitch * src_mt->region->cpp, src_mt->region->bo,
+ src_mt->region->pitch, src_mt->region->bo,
0, src_mt->region->tiling,
- dst_mt->region->pitch * dst_mt->region->cpp, dst_mt->region->bo,
+ dst_mt->region->pitch, dst_mt->region->bo,
0, dst_mt->region->tiling,
src_x, src_y,
dst_x, dst_y,
x += image_x;
y += image_y;
- map->stride = mt->region->pitch * mt->cpp;
+ map->stride = mt->region->pitch;
map->ptr = base + y * map->stride + x * mt->cpp;
}
if (!intelEmitCopyBlit(intel,
mt->region->cpp,
- mt->region->pitch * mt->region->cpp, mt->region->bo,
+ mt->region->pitch, mt->region->bo,
0, mt->region->tiling,
map->stride, map->bo,
0, I915_TILING_NONE,
image_y += map->y;
uint8_t *dst = intel_region_map(intel, mt->region, map->mode)
- + image_y * mt->region->pitch * mt->region->cpp
+ + image_y * mt->region->pitch
+ image_x * mt->region->cpp;
if (mt->etc_format == MESA_FORMAT_ETC1_RGB8)
- _mesa_etc1_unpack_rgba8888(dst, mt->region->pitch * mt->region->cpp,
+ _mesa_etc1_unpack_rgba8888(dst, mt->region->pitch,
map->ptr, map->stride,
map->w, map->h);
else
- _mesa_unpack_etc2_format(dst, mt->region->pitch * mt->region->cpp,
+ _mesa_unpack_etc2_format(dst, mt->region->pitch,
map->ptr, map->stride,
map->w, map->h, mt->etc_format);
map_x + s_image_x,
map_y + s_image_y,
intel->has_swizzling);
- ptrdiff_t z_offset = ((map_y + z_image_y) * z_mt->region->pitch +
+ ptrdiff_t z_offset = ((map_y + z_image_y) *
+ (z_mt->region->pitch / 4) +
(map_x + z_image_x));
uint8_t s = s_map[s_offset];
uint32_t z = z_map[z_offset];
x + s_image_x + map->x,
y + s_image_y + map->y,
intel->has_swizzling);
- ptrdiff_t z_offset = ((y + z_image_y) * z_mt->region->pitch +
+ ptrdiff_t z_offset = ((y + z_image_y) *
+ (z_mt->region->pitch / 4) +
(x + z_image_x));
if (map_z32f_x24s8) {
(GLubyte *)stipple,
sz,
color,
- dst->pitch * dst->cpp,
+ dst->pitch,
dst->bo,
0,
dst->tiling,
if (!intelEmitCopyBlit(intel,
src->cpp,
- src->pitch * src->cpp, src->bo, 0, src->tiling,
+ src->pitch, src->bo, 0, src->tiling,
rowLength * src->cpp, dst_buffer, dst_offset, false,
x, y,
dst_x, dst_y,
return NULL;
region = intel_region_alloc_internal(screen, cpp, width, height,
- aligned_pitch / cpp, tiling, buffer);
+ aligned_pitch, tiling, buffer);
if (region == NULL) {
drm_intel_bo_unreference(buffer);
return NULL;
{
GLuint i;
- dst_pitch *= cpp;
- src_pitch *= cpp;
dst += dst_x * cpp;
src += src_x * cpp;
dst += dst_y * dst_pitch;
return intelEmitCopyBlit(intel,
dst->cpp,
- src_pitch * src->cpp, src->bo, src_offset, src->tiling,
- dst->pitch * dst->cpp, dst->bo, dst_offset, dst->tiling,
+ src_pitch, src->bo, src_offset, src->tiling,
+ dst->pitch, dst->bo, dst_offset, dst->tiling,
srcx, srcy, dstx, dsty, width, height,
logicop);
}
uint32_t y, bool map_stencil_as_y_tiled)
{
int cpp = region->cpp;
- uint32_t pitch = region->pitch * cpp;
+ uint32_t pitch = region->pitch;
uint32_t tiling = region->tiling;
if (map_stencil_as_y_tiled) {
GLuint cpp; /**< bytes per pixel */
GLuint width; /**< in pixels */
GLuint height; /**< in pixels */
- GLuint pitch; /**< in pixels */
+ GLuint pitch; /**< in bytes */
GLubyte *map; /**< only non-NULL when region is actually mapped */
GLuint map_refcount; /**< Reference count for mapping */
continue;
}
+ assert(irb->mt->region->pitch % irb->mt->region->cpp == 0);
drm_intel_gem_bo_aub_dump_bmp(irb->mt->region->bo,
irb->draw_x,
irb->draw_y,
irb->Base.Base.Width,
irb->Base.Base.Height,
format,
- irb->mt->region->pitch *
- irb->mt->region->cpp,
+ irb->mt->region->pitch,
0);
}
}
{
switch (attrib) {
case __DRI_IMAGE_ATTRIB_STRIDE:
- *value = image->region->pitch * image->region->cpp;
+ *value = image->region->pitch;
return true;
case __DRI_IMAGE_ATTRIB_HANDLE:
*value = image->region->bo->handle;
static __DRIimage *
intel_from_planar(__DRIimage *parent, int plane, void *loaderPrivate)
{
- int width, height, offset, stride, dri_format, cpp, index, pitch;
+ int width, height, offset, stride, dri_format, index;
struct intel_image_format *f;
uint32_t mask_x, mask_y;
__DRIimage *image;
stride = parent->strides[index];
image = intel_allocate_image(dri_format, loaderPrivate);
- cpp = _mesa_get_format_bytes(image->format); /* safe since no none format */
- pitch = stride / cpp;
- if (offset + height * cpp * pitch > parent->region->bo->size) {
+ if (offset + height * stride > parent->region->bo->size) {
_mesa_warning(NULL, "intel_create_sub_image: subimage out of bounds");
free(image);
return NULL;
image->region->cpp = _mesa_get_format_bytes(image->format);
image->region->width = width;
image->region->height = height;
- image->region->pitch = pitch;
+ image->region->pitch = stride;
image->region->refcount = 1;
image->region->bo = parent->region->bo;
drm_intel_bo_reference(image->region->bo);
intelBuffer->base.attachment = attachment;
intelBuffer->base.cpp = intelBuffer->region->cpp;
- intelBuffer->base.pitch =
- intelBuffer->region->pitch * intelBuffer->region->cpp;
+ intelBuffer->base.pitch = intelBuffer->region->pitch;
return &intelBuffer->base;
}
/* blit from src buffer to texture */
if (!intelEmitCopyBlit(intel,
intelImage->mt->cpp,
- src_pitch * region->cpp,
+ src_pitch,
region->bo,
0,
region->tiling,
- intelImage->mt->region->pitch * intelImage->mt->cpp,
+ intelImage->mt->region->pitch,
intelImage->mt->region->bo,
0,
intelImage->mt->region->tiling,
struct intel_context *intel = intel_context(ctx);
struct intel_buffer_object *pbo = intel_buffer_object(unpack->BufferObj);
GLuint src_offset, src_stride;
- GLuint dst_x, dst_y, dst_stride;
+ GLuint dst_x, dst_y;
drm_intel_bo *dst_buffer, *src_buffer;
if (!_mesa_is_bufferobj(unpack->BufferObj))
intelImage->base.Base.Face,
&dst_x, &dst_y);
- dst_stride = intelImage->mt->region->pitch * intelImage->mt->region->cpp;
-
if (!intelEmitCopyBlit(intel,
intelImage->mt->cpp,
src_stride, src_buffer,
src_offset, false,
- dst_stride, dst_buffer, 0,
+ intelImage->mt->region->pitch, dst_buffer, 0,
intelImage->mt->region->tiling,
0, 0, dst_x, dst_y, image->Width, image->Height,
GL_COPY)) {
intel_texobj->needs_validate = true;
intel_image->mt->offset = offset;
- intel_image->base.RowStride = region->pitch;
+ assert(region->pitch % region->cpp == 0);
+ intel_image->base.RowStride = region->pitch / region->cpp;
/* Immediately validate the image to the object. */
intel_miptree_reference(&intel_texobj->mt, intel_image->mt);
}
bool ret;
- unsigned int dst_pitch = intelImage->mt->region->pitch *
- intelImage->mt->cpp;
drm_intel_gem_bo_unmap_gtt(temp_bo);
intelImage->mt->cpp,
dstRowStride,
temp_bo, 0, false,
- dst_pitch,
+ intelImage->mt->region->pitch,
intelImage->mt->region->bo, 0,
intelImage->mt->region->tiling,
0, 0, blit_x, blit_y, width, height,
const uint32_t cpp = 4; /* chars per pixel of GL_BGRA */
const uint32_t swizzle_width_pixels = 16;
- const uint32_t stride_bytes = image->mt->region->pitch * cpp;
+ const uint32_t stride_bytes = image->mt->region->pitch;
const uint32_t width_tiles = stride_bytes / tile_width_bytes;
for (uint32_t y_pixels = yoffset; y_pixels < y_max_pixels; ++y_pixels) {
*/
for (i = 0; i < mt->level[level].depth; i++) {
intel_miptree_get_image_offset(mt, level, i, &x, &y);
- intel_image->base.ImageOffsets[i] = x + y * mt->region->pitch;
+ intel_image->base.ImageOffsets[i] = x + y * (mt->region->pitch /
+ mt->region->cpp);
}
DBG("%s \n", __FUNCTION__);
intel_miptree_get_image_offset(mt, level, face, &x, &y);
DBG("%s: (%d,%d) -> (%d, %d)/%d\n",
- __FUNCTION__, face, level, x, y, mt->region->pitch * mt->cpp);
+ __FUNCTION__, face, level, x, y, mt->region->pitch);
intel_image->base.Map = intel_region_map(intel, mt->region, mode) +
- (x + y * mt->region->pitch) * mt->cpp;
+ x * mt->cpp + y * mt->region->pitch;
}
- intel_image->base.RowStride = mt->region->pitch;
+ assert(mt->region->pitch % mt->region->cpp == 0);
+ intel_image->base.RowStride = mt->region->pitch / mt->region->cpp;
}
static void