#include "main/vtxfmt.h"
#include "main/texobj.h"
#include "main/framebuffer.h"
+#include "main/stencil.h"
+#include "main/state.h"
-#include "vbo/vbo_context.h"
+#include "vbo/vbo.h"
#include "drivers/common/driverfuncs.h"
#include "drivers/common/meta.h"
#include "tnl/t_pipeline.h"
#include "util/ralloc.h"
#include "util/debug.h"
+#include "util/disk_cache.h"
#include "isl/isl.h"
/***************************************
fb->DefaultGeometry.NumSamples);
}
-static bool
-intel_disable_rb_aux_buffer(struct brw_context *brw, const struct brw_bo *bo)
-{
- const struct gl_framebuffer *fb = brw->ctx.DrawBuffer;
- bool found = false;
-
- for (unsigned i = 0; i < fb->_NumColorDrawBuffers; i++) {
- const struct intel_renderbuffer *irb =
- intel_renderbuffer(fb->_ColorDrawBuffers[i]);
-
- if (irb && irb->mt->bo == bo) {
- found = brw->draw_aux_buffer_disabled[i] = true;
- }
- }
-
- return found;
-}
-
static void
-intel_update_state(struct gl_context * ctx, GLuint new_state)
+intel_update_state(struct gl_context * ctx)
{
+ GLuint new_state = ctx->NewState;
struct brw_context *brw = brw_context(ctx);
- struct intel_texture_object *tex_obj;
- struct intel_renderbuffer *depth_irb;
if (ctx->swrast_context)
_swrast_InvalidateState(ctx, new_state);
- _vbo_InvalidateState(ctx, new_state);
brw->NewGLState |= new_state;
- _mesa_unlock_context_textures(ctx);
+ if (new_state & (_NEW_SCISSOR | _NEW_BUFFERS | _NEW_VIEWPORT))
+ _mesa_update_draw_buffer_bounds(ctx, ctx->DrawBuffer);
- /* Resolve the depth buffer's HiZ buffer. */
- depth_irb = intel_get_renderbuffer(ctx->DrawBuffer, BUFFER_DEPTH);
- if (depth_irb && depth_irb->mt) {
- intel_miptree_slice_resolve_hiz(brw, depth_irb->mt,
- depth_irb->mt_level,
- depth_irb->mt_layer);
+ if (new_state & (_NEW_STENCIL | _NEW_BUFFERS)) {
+ brw->stencil_enabled = _mesa_stencil_is_enabled(ctx);
+ brw->stencil_two_sided = _mesa_stencil_is_two_sided(ctx);
+ brw->stencil_write_enabled =
+ _mesa_stencil_is_write_enabled(ctx, brw->stencil_two_sided);
}
- memset(brw->draw_aux_buffer_disabled, 0,
- sizeof(brw->draw_aux_buffer_disabled));
-
- /* Resolve depth buffer and render cache of each enabled texture. */
- int maxEnabledUnit = ctx->Texture._MaxEnabledTexImageUnit;
- for (int i = 0; i <= maxEnabledUnit; i++) {
- if (!ctx->Texture.Unit[i]._Current)
- continue;
- tex_obj = intel_texture_object(ctx->Texture.Unit[i]._Current);
- if (!tex_obj || !tex_obj->mt)
- continue;
-
- /* We need inte_texture_object::_Format to be valid */
- intel_finalize_mipmap_tree(brw, i);
-
- bool aux_supported;
- intel_miptree_prepare_texture(brw, tex_obj->mt, tex_obj->_Format,
- &aux_supported);
-
- if (!aux_supported && brw->gen >= 9 &&
- intel_disable_rb_aux_buffer(brw, tex_obj->mt->bo)) {
- perf_debug("Sampling renderbuffer with non-compressible format - "
- "turning off compression");
- }
-
- brw_render_cache_set_check_flush(brw, tex_obj->mt->bo);
-
- if (tex_obj->base.StencilSampling ||
- tex_obj->mt->format == MESA_FORMAT_S_UINT8) {
- intel_update_r8stencil(brw, tex_obj->mt);
- }
- }
-
- /* Resolve color for each active shader image. */
- for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
- const struct gl_program *prog = ctx->_Shader->CurrentProgram[i];
-
- if (unlikely(prog && prog->info.num_images)) {
- for (unsigned j = 0; j < prog->info.num_images; j++) {
- struct gl_image_unit *u =
- &ctx->ImageUnits[prog->sh.ImageUnits[j]];
- tex_obj = intel_texture_object(u->TexObj);
-
- if (tex_obj && tex_obj->mt) {
- /* Access to images is implemented using indirect messages
- * against data port. Normal render target write understands
- * lossless compression but unfortunately the typed/untyped
- * read/write interface doesn't. Therefore even lossless
- * compressed surfaces need to be resolved prior to accessing
- * them. Hence skip setting INTEL_MIPTREE_IGNORE_CCS_E.
- */
- intel_miptree_all_slices_resolve_color(brw, tex_obj->mt, 0);
-
- if (intel_miptree_is_lossless_compressed(brw, tex_obj->mt) &&
- intel_disable_rb_aux_buffer(brw, tex_obj->mt->bo)) {
- perf_debug("Using renderbuffer as shader image - turning "
- "off lossless compression");
- }
-
- brw_render_cache_set_check_flush(brw, tex_obj->mt->bo);
- }
- }
- }
- }
-
- /* Resolve color buffers for non-coherent framebuffer fetch. */
- if (!ctx->Extensions.MESA_shader_framebuffer_fetch &&
- ctx->FragmentProgram._Current &&
- ctx->FragmentProgram._Current->info.outputs_read) {
- const struct gl_framebuffer *fb = ctx->DrawBuffer;
-
- for (unsigned i = 0; i < fb->_NumColorDrawBuffers; i++) {
- const struct intel_renderbuffer *irb =
- intel_renderbuffer(fb->_ColorDrawBuffers[i]);
-
- if (irb) {
- intel_miptree_prepare_fb_fetch(brw, irb->mt, irb->mt_level,
- irb->mt_layer, irb->layer_count);
- }
- }
- }
-
- struct gl_framebuffer *fb = ctx->DrawBuffer;
- for (int i = 0; i < fb->_NumColorDrawBuffers; i++) {
- struct intel_renderbuffer *irb =
- intel_renderbuffer(fb->_ColorDrawBuffers[i]);
-
- if (irb == NULL || irb->mt == NULL)
- continue;
-
- intel_miptree_prepare_render(brw, irb->mt, irb->mt_level,
- irb->mt_layer, irb->layer_count,
- ctx->Color.sRGBEnabled);
- }
-
- _mesa_lock_context_textures(ctx);
+ if (new_state & _NEW_POLYGON)
+ brw->polygon_front_bit = _mesa_polygon_get_front_bit(ctx);
if (new_state & _NEW_BUFFERS) {
intel_update_framebuffer(ctx, ctx->DrawBuffer);
intel_glFlush(ctx);
if (brw->batch.last_bo)
- brw_bo_wait_rendering(brw, brw->batch.last_bo);
+ brw_bo_wait_rendering(brw->batch.last_bo);
}
static void
brw_init_driver_functions(struct brw_context *brw,
struct dd_function_table *functions)
{
+ const struct gen_device_info *devinfo = &brw->screen->devinfo;
+
_mesa_init_driver_functions(functions);
/* GLX uses DRI2 invalidate events to handle window resizing.
intelInitTextureFuncs(functions);
intelInitTextureImageFuncs(functions);
- intelInitTextureSubImageFuncs(functions);
intelInitTextureCopyImageFuncs(functions);
intelInitCopyImageFuncs(functions);
intelInitClearFuncs(functions);
brwInitFragProgFuncs( functions );
brw_init_common_queryobj_functions(functions);
- if (brw->gen >= 8 || brw->is_haswell)
+ if (devinfo->gen >= 8 || devinfo->is_haswell)
hsw_init_queryobj_functions(functions);
- else if (brw->gen >= 6)
+ else if (devinfo->gen >= 6)
gen6_init_queryobj_functions(functions);
else
gen4_init_queryobj_functions(functions);
brw_init_compute_functions(functions);
- if (brw->gen >= 7)
- brw_init_conditional_render_functions(functions);
+ brw_init_conditional_render_functions(functions);
functions->QueryInternalFormat = brw_query_internal_format;
functions->EndTransformFeedback = hsw_end_transform_feedback;
functions->PauseTransformFeedback = hsw_pause_transform_feedback;
functions->ResumeTransformFeedback = hsw_resume_transform_feedback;
- } else if (brw->gen >= 7) {
+ } else if (devinfo->gen >= 7) {
functions->BeginTransformFeedback = gen7_begin_transform_feedback;
functions->EndTransformFeedback = gen7_end_transform_feedback;
functions->PauseTransformFeedback = gen7_pause_transform_feedback;
brw_get_transform_feedback_vertex_count;
}
- if (brw->gen >= 6)
+ if (devinfo->gen >= 6)
functions->GetSamplePosition = gen6_get_sample_position;
+
+ /* GL_ARB_get_program_binary */
+ brw_program_binary_init(brw->screen->deviceID);
+ functions->GetProgramBinaryDriverSHA1 = brw_get_program_binary_driver_sha1;
+ functions->ProgramBinarySerializeDriverBlob = brw_program_serialize_nir;
+ functions->ProgramBinaryDeserializeDriverBlob =
+ brw_deserialize_program_binary;
}
static void
brw_initialize_context_constants(struct brw_context *brw)
{
+ const struct gen_device_info *devinfo = &brw->screen->devinfo;
struct gl_context *ctx = &brw->ctx;
const struct brw_compiler *compiler = brw->screen->compiler;
const bool stage_exists[MESA_SHADER_STAGES] = {
[MESA_SHADER_VERTEX] = true,
- [MESA_SHADER_TESS_CTRL] = brw->gen >= 7,
- [MESA_SHADER_TESS_EVAL] = brw->gen >= 7,
- [MESA_SHADER_GEOMETRY] = brw->gen >= 6,
+ [MESA_SHADER_TESS_CTRL] = devinfo->gen >= 7,
+ [MESA_SHADER_TESS_EVAL] = devinfo->gen >= 7,
+ [MESA_SHADER_GEOMETRY] = devinfo->gen >= 6,
[MESA_SHADER_FRAGMENT] = true,
[MESA_SHADER_COMPUTE] =
- ((ctx->API == API_OPENGL_COMPAT || ctx->API == API_OPENGL_CORE) &&
+ (_mesa_is_desktop_gl(ctx) &&
ctx->Const.MaxComputeWorkGroupSize[0] >= 1024) ||
(ctx->API == API_OPENGLES2 &&
- ctx->Const.MaxComputeWorkGroupSize[0] >= 128) ||
- _mesa_extension_override_enables.ARB_compute_shader,
+ ctx->Const.MaxComputeWorkGroupSize[0] >= 128),
};
unsigned num_stages = 0;
}
unsigned max_samplers =
- brw->gen >= 8 || brw->is_haswell ? BRW_MAX_TEX_UNIT : 16;
+ devinfo->gen >= 8 || devinfo->is_haswell ? BRW_MAX_TEX_UNIT : 16;
ctx->Const.MaxDualSourceDrawBuffers = 1;
ctx->Const.MaxDrawBuffers = BRW_MAX_DRAW_BUFFERS;
ctx->Const.MaxTextureCoordUnits = 8; /* Mesa limit */
ctx->Const.MaxImageUnits = MAX_IMAGE_UNITS;
- if (brw->gen >= 7) {
+ if (devinfo->gen >= 7) {
ctx->Const.MaxRenderbufferSize = 16384;
ctx->Const.MaxTextureLevels = MIN2(15 /* 16384 */, MAX_TEXTURE_LEVELS);
ctx->Const.MaxCubeTextureLevels = 15; /* 16384 */
ctx->Const.MaxCubeTextureLevels = 14; /* 8192 */
}
ctx->Const.Max3DTextureLevels = 12; /* 2048 */
- ctx->Const.MaxArrayTextureLayers = brw->gen >= 7 ? 2048 : 512;
+ ctx->Const.MaxArrayTextureLayers = devinfo->gen >= 7 ? 2048 : 512;
ctx->Const.MaxTextureMbytes = 1536;
- ctx->Const.MaxTextureRectSize = 1 << 12;
+ ctx->Const.MaxTextureRectSize = devinfo->gen >= 7 ? 16384 : 8192;
ctx->Const.MaxTextureMaxAnisotropy = 16.0;
ctx->Const.MaxTextureLodBias = 15.0;
ctx->Const.StripTextureBorder = true;
- if (brw->gen >= 7) {
+ if (devinfo->gen >= 7) {
ctx->Const.MaxProgramTextureGatherComponents = 4;
ctx->Const.MinProgramTextureGatherOffset = -32;
ctx->Const.MaxProgramTextureGatherOffset = 31;
- } else if (brw->gen == 6) {
+ } else if (devinfo->gen == 6) {
ctx->Const.MaxProgramTextureGatherComponents = 1;
ctx->Const.MinProgramTextureGatherOffset = -8;
ctx->Const.MaxProgramTextureGatherOffset = 7;
ctx->Const.MinLineWidth = 1.0;
ctx->Const.MinLineWidthAA = 1.0;
- if (brw->gen >= 6) {
+ if (devinfo->gen >= 6) {
ctx->Const.MaxLineWidth = 7.375;
ctx->Const.MaxLineWidthAA = 7.375;
ctx->Const.LineWidthGranularity = 0.125;
ctx->Const.MaxPointSizeAA = 255.0;
ctx->Const.PointSizeGranularity = 1.0;
- if (brw->gen >= 5 || brw->is_g4x)
+ if (devinfo->gen >= 5 || devinfo->is_g4x)
ctx->Const.MaxClipPlanes = 8;
ctx->Const.GLSLTessLevelsAsInputs = true;
- ctx->Const.LowerTCSPatchVerticesIn = brw->gen >= 8;
- ctx->Const.LowerTESPatchVerticesIn = true;
ctx->Const.PrimitiveRestartForPatches = true;
ctx->Const.Program[MESA_SHADER_VERTEX].MaxNativeInstructions = 16 * 1024;
* that affect provoking vertex decision. Always use last vertex
* convention for quad primitive which works as expected for now.
*/
- if (brw->gen >= 6)
+ if (devinfo->gen >= 6)
ctx->Const.QuadsFollowProvokingVertexConvention = false;
ctx->Const.NativeIntegers = true;
* the element in the buffer."
*
* However, unaligned accesses are slower, so enforce buffer alignment.
+ *
+ * In order to push UBO data, 3DSTATE_CONSTANT_XS imposes an additional
+ * restriction: the start of the buffer needs to be 32B aligned.
*/
- ctx->Const.UniformBufferOffsetAlignment = 16;
+ ctx->Const.UniformBufferOffsetAlignment = 32;
/* ShaderStorageBufferOffsetAlignment should be a cacheline (64 bytes) so
* that we can safely have the CPU and GPU writing the same SSBO on
ctx->Const.TextureBufferOffsetAlignment = 16;
ctx->Const.MaxTextureBufferSize = 128 * 1024 * 1024;
- if (brw->gen >= 6) {
+ if (devinfo->gen >= 6) {
ctx->Const.MaxVarying = 32;
ctx->Const.Program[MESA_SHADER_VERTEX].MaxOutputComponents = 128;
- ctx->Const.Program[MESA_SHADER_GEOMETRY].MaxInputComponents = 64;
+ ctx->Const.Program[MESA_SHADER_GEOMETRY].MaxInputComponents =
+ compiler->scalar_stage[MESA_SHADER_GEOMETRY] ? 128 : 64;
ctx->Const.Program[MESA_SHADER_GEOMETRY].MaxOutputComponents = 128;
ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxInputComponents = 128;
ctx->Const.Program[MESA_SHADER_TESS_CTRL].MaxInputComponents = 128;
brw->screen->compiler->glsl_compiler_options[i];
}
- if (brw->gen >= 7) {
+ if (devinfo->gen >= 7) {
ctx->Const.MaxViewportWidth = 32768;
ctx->Const.MaxViewportHeight = 32768;
}
/* ARB_viewport_array, OES_viewport_array */
- if (brw->gen >= 6) {
+ if (devinfo->gen >= 6) {
ctx->Const.MaxViewports = GEN6_NUM_VIEWPORTS;
ctx->Const.ViewportSubpixelBits = 0;
}
/* ARB_gpu_shader5 */
- if (brw->gen >= 7)
+ if (devinfo->gen >= 7)
ctx->Const.MaxVertexStreams = MIN2(4, MAX_VERTEX_STREAMS);
/* ARB_framebuffer_no_attachments */
/* OES_primitive_bounding_box */
ctx->Const.NoPrimitiveBoundingBoxOutput = true;
+
+ /* TODO: We should be able to use STD430 packing by default on all hardware
+ * but some piglit tests [1] currently fail on SNB when this is enabled.
+ * The problem is the messages we're using for doing uniform pulls
+ * in the vec4 back-end on SNB is the OWORD block load instruction, which
+ * takes its offset in units of OWORDS (16 bytes). On IVB+, we use the
+ * sampler which doesn't have these restrictions.
+ *
+ * In the scalar back-end, we use the sampler for dynamic uniform loads and
+ * pull an entire cache line at a time for constant offset loads both of
+ * which support almost any alignment.
+ *
+ * [1] glsl-1.40/uniform_buffer/vs-float-array-variable-index.shader_test
+ */
+ if (devinfo->gen >= 7)
+ ctx->Const.UseSTD430AsDefaultPacking = true;
+
+ if (!(ctx->Const.ContextFlags & GL_CONTEXT_FLAG_DEBUG_BIT))
+ ctx->Const.AllowMappedBuffersDuringExecution = true;
+
+ /* GL_ARB_get_program_binary */
+ ctx->Const.NumProgramBinaryFormats = 1;
}
static void
struct gen_device_info *devinfo = &brw->screen->devinfo;
/* FINISHME: Do this for all platforms that the kernel supports */
- if (brw->is_cherryview &&
+ if (devinfo->is_cherryview &&
screen->subslice_total > 0 && screen->eu_total > 0) {
/* Logical CS threads = EUs per subslice * 7 threads per EU */
uint32_t max_cs_threads = screen->eu_total / screen->subslice_total * 7;
static void
brw_process_driconf_options(struct brw_context *brw)
{
+ const struct gen_device_info *devinfo = &brw->screen->devinfo;
struct gl_context *ctx = &brw->ctx;
driOptionCache *options = &brw->optionCache;
if (INTEL_DEBUG & DEBUG_NO_HIZ) {
brw->has_hiz = false;
/* On gen6, you can only do separate stencil with HIZ. */
- if (brw->gen == 6)
+ if (devinfo->gen == 6)
brw->has_separate_stencil = false;
}
+ if (driQueryOptionb(options, "mesa_no_error"))
+ ctx->Const.ContextFlags |= GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR;
+
if (driQueryOptionb(options, "always_flush_batch")) {
fprintf(stderr, "flushing batchbuffer before/after each draw call\n");
brw->always_flush_batch = true;
brw->dual_color_blend_by_location =
driQueryOptionb(options, "dual_color_blend_by_location");
+
+ ctx->Const.AllowGLSLCrossStageInterpolationMismatch =
+ driQueryOptionb(options, "allow_glsl_cross_stage_interpolation_mismatch");
+
+ ctx->Const.dri_config_options_sha1 = ralloc_array(brw, unsigned char, 20);
+ driComputeOptionsSha1(&brw->screen->optionCache,
+ ctx->Const.dri_config_options_sha1);
}
GLboolean
brwCreateContext(gl_api api,
- const struct gl_config *mesaVis,
- __DRIcontext *driContextPriv,
- unsigned major_version,
- unsigned minor_version,
- uint32_t flags,
- bool notify_reset,
+ const struct gl_config *mesaVis,
+ __DRIcontext *driContextPriv,
+ const struct __DriverContextConfig *ctx_config,
unsigned *dri_ctx_error,
- void *sharedContextPrivate)
+ void *sharedContextPrivate)
{
struct gl_context *shareCtx = (struct gl_context *) sharedContextPrivate;
struct intel_screen *screen = driContextPriv->driScreenPriv->driverPrivate;
/* Only allow the __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS flag if the kernel
* provides us with context reset notifications.
*/
- uint32_t allowed_flags = __DRI_CTX_FLAG_DEBUG
- | __DRI_CTX_FLAG_FORWARD_COMPATIBLE;
+ uint32_t allowed_flags = __DRI_CTX_FLAG_DEBUG |
+ __DRI_CTX_FLAG_FORWARD_COMPATIBLE |
+ __DRI_CTX_FLAG_NO_ERROR;
if (screen->has_context_reset_notification)
allowed_flags |= __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS;
- if (flags & ~allowed_flags) {
+ if (ctx_config->flags & ~allowed_flags) {
*dri_ctx_error = __DRI_CTX_ERROR_UNKNOWN_FLAG;
return false;
}
+ if (ctx_config->attribute_mask &
+ ~(__DRIVER_CONTEXT_ATTRIB_RESET_STRATEGY |
+ __DRIVER_CONTEXT_ATTRIB_PRIORITY)) {
+ *dri_ctx_error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
+ return false;
+ }
+
+ bool notify_reset =
+ ((ctx_config->attribute_mask & __DRIVER_CONTEXT_ATTRIB_RESET_STRATEGY) &&
+ ctx_config->reset_strategy != __DRI_CTX_RESET_NO_NOTIFICATION);
+
struct brw_context *brw = rzalloc(NULL, struct brw_context);
if (!brw) {
fprintf(stderr, "%s: failed to alloc context\n", __func__);
brw->screen = screen;
brw->bufmgr = screen->bufmgr;
- brw->gen = devinfo->gen;
- brw->gt = devinfo->gt;
- brw->is_g4x = devinfo->is_g4x;
- brw->is_baytrail = devinfo->is_baytrail;
- brw->is_haswell = devinfo->is_haswell;
- brw->is_cherryview = devinfo->is_cherryview;
- brw->is_broxton = devinfo->is_broxton;
- brw->has_llc = devinfo->has_llc;
brw->has_hiz = devinfo->has_hiz_and_separate_stencil;
brw->has_separate_stencil = devinfo->has_hiz_and_separate_stencil;
- brw->has_pln = devinfo->has_pln;
- brw->has_compr4 = devinfo->has_compr4;
- brw->has_surface_tile_offset = devinfo->has_surface_tile_offset;
- brw->has_negative_rhw_bug = devinfo->has_negative_rhw_bug;
- brw->needs_unlit_centroid_workaround =
- devinfo->needs_unlit_centroid_workaround;
-
- brw->must_use_separate_stencil = devinfo->must_use_separate_stencil;
+
brw->has_swizzling = screen->hw_has_swizzling;
- isl_device_init(&brw->isl_dev, devinfo, screen->hw_has_swizzling);
+ brw->isl_dev = screen->isl_dev;
brw->vs.base.stage = MESA_SHADER_VERTEX;
brw->tcs.base.stage = MESA_SHADER_TESS_CTRL;
brw->tes.base.stage = MESA_SHADER_TESS_EVAL;
brw->gs.base.stage = MESA_SHADER_GEOMETRY;
brw->wm.base.stage = MESA_SHADER_FRAGMENT;
- if (brw->gen >= 8) {
- gen8_init_vtable_surface_functions(brw);
+ brw->cs.base.stage = MESA_SHADER_COMPUTE;
+ if (devinfo->gen >= 8) {
brw->vtbl.emit_depth_stencil_hiz = gen8_emit_depth_stencil_hiz;
- } else if (brw->gen >= 7) {
- gen7_init_vtable_surface_functions(brw);
+ } else if (devinfo->gen >= 7) {
brw->vtbl.emit_depth_stencil_hiz = gen7_emit_depth_stencil_hiz;
- } else if (brw->gen >= 6) {
- gen6_init_vtable_surface_functions(brw);
+ } else if (devinfo->gen >= 6) {
brw->vtbl.emit_depth_stencil_hiz = gen6_emit_depth_stencil_hiz;
} else {
- gen4_init_vtable_surface_functions(brw);
brw->vtbl.emit_depth_stencil_hiz = brw_emit_depth_stencil_hiz;
}
return false;
}
- driContextSetFlags(ctx, flags);
+ driContextSetFlags(ctx, ctx_config->flags);
/* Initialize the software rasterizer and helper modules.
*
intel_fbo_init(brw);
- intel_batchbuffer_init(&brw->batch, brw->bufmgr, brw->has_llc);
+ intel_batchbuffer_init(brw);
- if (brw->gen >= 6) {
+ if (devinfo->gen >= 6) {
/* Create a new hardware context. Using a hardware context means that
* our GPU state will be saved/restored on context switch, allowing us
* to assume that the GPU is in the same state we left it in.
intelDestroyContext(driContextPriv);
return false;
}
+
+ int hw_priority = BRW_CONTEXT_MEDIUM_PRIORITY;
+ if (ctx_config->attribute_mask & __DRIVER_CONTEXT_ATTRIB_PRIORITY) {
+ switch (ctx_config->priority) {
+ case __DRI_CTX_PRIORITY_LOW:
+ hw_priority = BRW_CONTEXT_LOW_PRIORITY;
+ break;
+ case __DRI_CTX_PRIORITY_HIGH:
+ hw_priority = BRW_CONTEXT_HIGH_PRIORITY;
+ break;
+ }
+ }
+ if (hw_priority != I915_CONTEXT_DEFAULT_PRIORITY &&
+ brw_hw_context_set_priority(brw->bufmgr, brw->hw_ctx, hw_priority)) {
+ fprintf(stderr,
+ "Failed to set priority [%d:%d] for hardware context.\n",
+ ctx_config->priority, hw_priority);
+ intelDestroyContext(driContextPriv);
+ return false;
+ }
}
if (brw_init_pipe_control(brw, devinfo)) {
return false;
}
+ if (devinfo->gen == 10) {
+ fprintf(stderr,
+ "WARNING: i965 does not fully support Gen10 yet.\n"
+ "Instability or lower performance might occur.\n");
+
+ }
+
brw_init_state(brw);
intelInitExtensions(ctx);
brw->urb.size = devinfo->urb.size;
- if (brw->gen == 6)
+ if (devinfo->gen == 6)
brw->urb.gs_present = false;
brw->prim_restart.in_progress = false;
brw_draw_init( brw );
- if ((flags & __DRI_CTX_FLAG_DEBUG) != 0) {
+ if ((ctx_config->flags & __DRI_CTX_FLAG_DEBUG) != 0) {
/* Turn on some extra GL_ARB_debug_output generation. */
brw->perf_debug = true;
}
- if ((flags & __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS) != 0) {
+ if ((ctx_config->flags & __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS) != 0) {
ctx->Const.ContextFlags |= GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB;
ctx->Const.RobustAccess = GL_TRUE;
}
if (INTEL_DEBUG & DEBUG_SHADER_TIME)
brw_init_shader_time(brw);
+ _mesa_override_extensions(ctx);
_mesa_compute_version(ctx);
_mesa_initialize_dispatch_tables(ctx);
vbo_use_buffer_objects(ctx);
vbo_always_unmap_buffers(ctx);
+ brw->ctx.Cache = brw->screen->disk_cache;
+
return true;
}
struct brw_context *brw =
(struct brw_context *) driContextPriv->driverPrivate;
struct gl_context *ctx = &brw->ctx;
+ const struct gen_device_info *devinfo = &brw->screen->devinfo;
_mesa_meta_free(&brw->ctx);
brw_destroy_shader_time(brw);
}
- if (brw->gen >= 6)
+ if (devinfo->gen >= 6)
blorp_finish(&brw->blorp);
brw_destroy_state(brw);
brw_draw_destroy(brw);
brw_bo_unreference(brw->curbe.curbe_bo);
- if (brw->vs.base.scratch_bo)
- brw_bo_unreference(brw->vs.base.scratch_bo);
- if (brw->tcs.base.scratch_bo)
- brw_bo_unreference(brw->tcs.base.scratch_bo);
- if (brw->tes.base.scratch_bo)
- brw_bo_unreference(brw->tes.base.scratch_bo);
- if (brw->gs.base.scratch_bo)
- brw_bo_unreference(brw->gs.base.scratch_bo);
- if (brw->wm.base.scratch_bo)
- brw_bo_unreference(brw->wm.base.scratch_bo);
+
+ brw_bo_unreference(brw->vs.base.scratch_bo);
+ brw_bo_unreference(brw->tcs.base.scratch_bo);
+ brw_bo_unreference(brw->tes.base.scratch_bo);
+ brw_bo_unreference(brw->gs.base.scratch_bo);
+ brw_bo_unreference(brw->wm.base.scratch_bo);
+
+ brw_bo_unreference(brw->vs.base.push_const_bo);
+ brw_bo_unreference(brw->tcs.base.push_const_bo);
+ brw_bo_unreference(brw->tes.base.push_const_bo);
+ brw_bo_unreference(brw->gs.base.push_const_bo);
+ brw_bo_unreference(brw->wm.base.push_const_bo);
brw_destroy_hw_context(brw->bufmgr, brw->hw_ctx);
*
* Unfortunately, renderbuffer setup happens before a context is created. So
* in intel_screen.c we always set up sRGB, and here, if you're a GLES2/3
- * context (without an sRGB visual, though we don't have sRGB visuals exposed
- * yet), we go turn that back off before anyone finds out.
+ * context (without an sRGB visual), we go turn that back off before anyone
+ * finds out.
*/
static void
intel_gles3_srgb_workaround(struct brw_context *brw,
if (_mesa_is_desktop_gl(ctx) || !fb->Visual.sRGBCapable)
return;
- /* Some day when we support the sRGB capable bit on visuals available for
- * GLES, we'll need to respect that and not disable things here.
- */
- fb->Visual.sRGBCapable = false;
for (int i = 0; i < BUFFER_COUNT; i++) {
struct gl_renderbuffer *rb = fb->Attachment[i].Renderbuffer;
+
+ /* Check if sRGB was specifically asked for. */
+ struct intel_renderbuffer *irb = intel_get_renderbuffer(fb, i);
+ if (irb && irb->need_srgb)
+ return;
+
if (rb)
rb->Format = _mesa_get_srgb_format_linear(rb->Format);
}
+ /* Disable sRGB from framebuffers that are not compatible. */
+ fb->Visual.sRGBCapable = false;
}
GLboolean
__DRIdrawable * driReadPriv)
{
struct brw_context *brw;
- GET_CURRENT_CONTEXT(curCtx);
if (driContextPriv)
brw = (struct brw_context *) driContextPriv->driverPrivate;
else
brw = NULL;
- /* According to the glXMakeCurrent() man page: "Pending commands to
- * the previous context, if any, are flushed before it is released."
- * But only flush if we're actually changing contexts.
- */
- if (brw_context(curCtx) && brw_context(curCtx) != brw) {
- _mesa_flush(curCtx);
- }
-
if (driContextPriv) {
struct gl_context *ctx = &brw->ctx;
struct gl_framebuffer *fb, *readFb;
intel_resolve_for_dri2_flush(struct brw_context *brw,
__DRIdrawable *drawable)
{
- if (brw->gen < 6) {
+ const struct gen_device_info *devinfo = &brw->screen->devinfo;
+
+ if (devinfo->gen < 6) {
/* MSAA and fast color clear are not supported, so don't waste time
* checking whether a resolve is needed.
*/
rb = intel_get_renderbuffer(fb, buffers[i]);
if (rb == NULL || rb->mt == NULL)
continue;
- if (rb->mt->num_samples <= 1) {
+ if (rb->mt->surf.samples == 1) {
assert(rb->mt_layer == 0 && rb->mt_level == 0 &&
rb->layer_count == 1);
- intel_miptree_prepare_access(brw, rb->mt, 0, 1, 0, 1, false, false);
+ intel_miptree_prepare_external(brw, rb->mt);
} else {
intel_renderbuffer_downsample(brw, rb);
}
return;
}
- intel_update_winsys_renderbuffer_miptree(brw, rb, bo,
- drawable->w, drawable->h,
- buffer->pitch);
+ uint32_t tiling, swizzle;
+ brw_bo_get_tiling(bo, &tiling, &swizzle);
+
+ struct intel_mipmap_tree *mt =
+ intel_miptree_create_for_bo(brw,
+ bo,
+ intel_rb_format(rb),
+ 0,
+ drawable->w,
+ drawable->h,
+ 1,
+ buffer->pitch,
+ isl_tiling_from_i915_tiling(tiling),
+ MIPTREE_CREATE_DEFAULT);
+ if (!mt) {
+ brw_bo_unreference(bo);
+ return;
+ }
+
+ /* We got this BO from X11. We cana't assume that we have coherent texture
+ * access because X may suddenly decide to use it for scan-out which would
+ * destroy coherency.
+ */
+ bo->cache_coherent = false;
+
+ if (!intel_update_winsys_renderbuffer_miptree(brw, rb, mt,
+ drawable->w, drawable->h,
+ buffer->pitch)) {
+ brw_bo_unreference(bo);
+ intel_miptree_release(&mt);
+ return;
+ }
if (_mesa_is_front_buffer_drawing(fb) &&
(buffer->attachment == __DRI_BUFFER_FRONT_LEFT ||
if (last_mt && last_mt->bo == buffer->bo)
return;
- intel_update_winsys_renderbuffer_miptree(intel, rb, buffer->bo,
- buffer->width, buffer->height,
- buffer->pitch);
+ struct intel_mipmap_tree *mt =
+ intel_miptree_create_for_dri_image(intel, buffer, GL_TEXTURE_2D,
+ intel_rb_format(rb), true);
+ if (!mt)
+ return;
+
+ if (!intel_update_winsys_renderbuffer_miptree(intel, rb, mt,
+ buffer->width, buffer->height,
+ buffer->pitch)) {
+ intel_miptree_release(&mt);
+ return;
+ }
if (_mesa_is_front_buffer_drawing(fb) &&
buffer_type == __DRI_IMAGE_BUFFER_FRONT &&