*/
#include "main/mtypes.h"
#include "main/samplerobj.h"
-#include "main/texstore.h"
#include "program/prog_parameter.h"
#include "intel_mipmap_tree.h"
struct gl_sampler_object *sampler = _mesa_get_samplerobj(ctx, unit);
const GLuint surf_index = SURF_INDEX_TEXTURE(unit);
struct gen7_surface_state *surf;
+ int width, height, depth;
+
+ intel_miptree_get_dimensions_for_image(firstImage, &width, &height, &depth);
surf = brw_state_batch(brw, AUB_TRACE_SURFACE_STATE,
sizeof(*surf), 32, &brw->wm.surf_offset[surf_index]);
* - render_cache_read_write (exists on gen6 but ignored here)
*/
- surf->ss1.base_addr = intelObj->mt->region->buffer->offset; /* reloc */
+ surf->ss1.base_addr = intelObj->mt->region->bo->offset; /* reloc */
- surf->ss2.width = firstImage->Width - 1;
- surf->ss2.height = firstImage->Height - 1;
+ surf->ss2.width = width - 1;
+ surf->ss2.height = height - 1;
surf->ss3.pitch = (intelObj->mt->region->pitch * intelObj->mt->cpp) - 1;
- surf->ss3.depth = firstImage->Depth - 1;
+ surf->ss3.depth = depth - 1;
/* ss4: ignored? */
drm_intel_bo_emit_reloc(brw->intel.batch.bo,
brw->wm.surf_offset[surf_index] +
offsetof(struct gen7_surface_state, ss1),
- intelObj->mt->region->buffer, 0,
+ intelObj->mt->region->bo, 0,
I915_GEM_DOMAIN_SAMPLER, 0);
}
I915_GEM_DOMAIN_SAMPLER, 0);
}
-/**
- * Updates surface / buffer for fragment shader constant buffer, if
- * one is required.
- *
- * This consumes the state updates for the constant buffer, and produces
- * BRW_NEW_WM_SURFACES to get picked up by brw_prepare_wm_surfaces for
- * inclusion in the binding table.
- */
-static void upload_wm_constant_surface(struct brw_context *brw)
-{
- GLuint surf = SURF_INDEX_FRAG_CONST_BUFFER;
- struct brw_fragment_program *fp =
- (struct brw_fragment_program *) brw->fragment_program;
- const struct gl_program_parameter_list *params =
- fp->program.Base.Parameters;
-
- /* If there's no constant buffer, then no surface BO is needed to point at
- * it.
- */
- if (brw->wm.const_bo == 0) {
- if (brw->wm.surf_offset[surf]) {
- brw->state.dirty.brw |= BRW_NEW_WM_SURFACES;
- brw->wm.surf_offset[surf] = 0;
- }
- return;
- }
-
- gen7_create_constant_surface(brw, brw->wm.const_bo, params->NumParameters,
- &brw->wm.surf_offset[surf]);
- brw->state.dirty.brw |= BRW_NEW_WM_SURFACES;
-}
-
-const struct brw_tracked_state gen7_wm_constant_surface = {
- .dirty = {
- .mesa = 0,
- .brw = (BRW_NEW_WM_CONSTBUF |
- BRW_NEW_BATCH),
- .cache = 0
- },
- .emit = upload_wm_constant_surface,
-};
-
static void
gen7_update_null_renderbuffer_surface(struct brw_context *brw, unsigned unit)
{
surf->ss0.surface_type = BRW_SURFACE_2D;
/* reloc */
surf->ss1.base_addr = intel_renderbuffer_tile_offsets(irb, &tile_x, &tile_y);
- surf->ss1.base_addr += region->buffer->offset; /* reloc */
+ surf->ss1.base_addr += region->bo->offset; /* reloc */
assert(brw->has_surface_tile_offset);
/* Note that the low bits of these fields are missing, so
drm_intel_bo_emit_reloc(brw->intel.batch.bo,
brw->wm.surf_offset[unit] +
offsetof(struct gen7_surface_state, ss1),
- region->buffer,
- surf->ss1.base_addr - region->buffer->offset,
+ region->bo,
+ surf->ss1.base_addr - region->bo->offset,
I915_GEM_DOMAIN_RENDER,
I915_GEM_DOMAIN_RENDER);
}
-static void
-prepare_wm_surfaces(struct brw_context *brw)
-{
- struct gl_context *ctx = &brw->intel.ctx;
- int i;
- int nr_surfaces = 0;
-
- if (ctx->DrawBuffer->_NumColorDrawBuffers >= 1) {
- for (i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers; i++) {
- struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[i];
- struct intel_renderbuffer *irb = intel_renderbuffer(rb);
- struct intel_region *region = irb ? irb->region : NULL;
-
- if (region)
- brw_add_validated_bo(brw, region->buffer);
- nr_surfaces = SURF_INDEX_DRAW(i) + 1;
- }
- }
-
- if (brw->wm.const_bo) {
- brw_add_validated_bo(brw, brw->wm.const_bo);
- nr_surfaces = SURF_INDEX_FRAG_CONST_BUFFER + 1;
- }
-
- for (i = 0; i < BRW_MAX_TEX_UNIT; i++) {
- const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i];
- struct gl_texture_object *tObj = texUnit->_Current;
- struct intel_texture_object *intelObj = intel_texture_object(tObj);
-
- if (texUnit->_ReallyEnabled) {
- brw_add_validated_bo(brw, intelObj->mt->region->buffer);
- nr_surfaces = SURF_INDEX_TEXTURE(i) + 1;
- }
- }
-
- /* Have to update this in our prepare, since the unit's prepare
- * relies on it.
- */
- if (brw->wm.nr_surfaces != nr_surfaces) {
- brw->wm.nr_surfaces = nr_surfaces;
- brw->state.dirty.brw |= BRW_NEW_NR_WM_SURFACES;
- }
-}
-
-/**
- * Constructs the set of surface state objects pointed to by the
- * binding table.
- */
-static void
-upload_wm_surfaces(struct brw_context *brw)
+void
+gen7_init_vtable_surface_functions(struct brw_context *brw)
{
- struct gl_context *ctx = &brw->intel.ctx;
- GLuint i;
-
- /* _NEW_BUFFERS | _NEW_COLOR */
- /* Update surfaces for drawing buffers */
- if (ctx->DrawBuffer->_NumColorDrawBuffers >= 1) {
- for (i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers; i++) {
- if (intel_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[i])) {
- gen7_update_renderbuffer_surface(brw,
- ctx->DrawBuffer->_ColorDrawBuffers[i], i);
- } else {
- gen7_update_null_renderbuffer_surface(brw, i);
- }
- }
- } else {
- gen7_update_null_renderbuffer_surface(brw, 0);
- }
-
- /* Update surfaces for textures */
- for (i = 0; i < BRW_MAX_TEX_UNIT; i++) {
- const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i];
- const GLuint surf = SURF_INDEX_TEXTURE(i);
-
- /* _NEW_TEXTURE */
- if (texUnit->_ReallyEnabled) {
- gen7_update_texture_surface(ctx, i);
- } else {
- brw->wm.surf_offset[surf] = 0;
- }
- }
+ struct intel_context *intel = &brw->intel;
- brw->state.dirty.brw |= BRW_NEW_WM_SURFACES;
+ intel->vtbl.update_texture_surface = gen7_update_texture_surface;
+ intel->vtbl.update_renderbuffer_surface = gen7_update_renderbuffer_surface;
+ intel->vtbl.update_null_renderbuffer_surface =
+ gen7_update_null_renderbuffer_surface;
+ intel->vtbl.create_constant_surface = gen7_create_constant_surface;
}
-
-const struct brw_tracked_state gen7_wm_surfaces = {
- .dirty = {
- .mesa = (_NEW_COLOR |
- _NEW_TEXTURE |
- _NEW_BUFFERS),
- .brw = BRW_NEW_BATCH,
- .cache = 0
- },
- .prepare = prepare_wm_surfaces,
- .emit = upload_wm_surfaces,
-};