*/
#include "main/enums.h"
-#include "main/imports.h"
#include "main/macros.h"
#include "main/mtypes.h"
#include "main/fbobject.h"
#include "main/condrender.h"
#include "util/hash_table.h"
#include "util/set.h"
+#include "util/u_memory.h"
#include "swrast/swrast.h"
#include "drivers/common/meta.h"
GLuint x, GLuint y, GLuint w, GLuint h,
GLbitfield mode,
GLubyte **out_map,
- GLint *out_stride)
+ GLint *out_stride,
+ bool flip_y)
{
struct brw_context *brw = brw_context(ctx);
struct swrast_renderbuffer *srb = (struct swrast_renderbuffer *)rb;
* upside-down. So we need to ask for a rectangle on flipped vertically, and
* we then return a pointer to the bottom of it with a negative stride.
*/
- if (rb->Name == 0) {
+ if (flip_y) {
y = rb->Height - y - h;
}
intel_miptree_map(brw, mt, irb->mt_level, irb->mt_layer,
x, y, w, h, mode, &map, &stride);
- if (rb->Name == 0) {
+ if (flip_y) {
map += (h - 1) * stride;
stride = -stride;
}
intel_renderbuffer_format(struct gl_context * ctx, GLenum internalFormat)
{
struct brw_context *brw = brw_context(ctx);
- MAYBE_UNUSED const struct gen_device_info *devinfo = &brw->screen->devinfo;
+ ASSERTED const struct gen_device_info *devinfo = &brw->screen->devinfo;
switch (internalFormat) {
default:
assert(rb->Format != MESA_FORMAT_NONE);
rb->NumSamples = intel_quantize_num_samples(screen, rb->NumSamples);
+ rb->NumStorageSamples = rb->NumSamples;
rb->Width = width;
rb->Height = height;
rb->_BaseFormat = _mesa_get_format_base_format(rb->Format);
return intel_alloc_private_renderbuffer_storage(ctx, rb, internalFormat, width, height);
}
+static mesa_format
+fallback_rgbx_to_rgba(struct intel_screen *screen, struct gl_renderbuffer *rb,
+ mesa_format original_format)
+{
+ mesa_format format = original_format;
+
+ /* The base format and internal format must be derived from the user-visible
+ * format (that is, the gl_config's format), even if we internally use
+ * choose a different format for the renderbuffer. Otherwise, rendering may
+ * use incorrect channel write masks.
+ */
+ rb->_BaseFormat = _mesa_get_format_base_format(original_format);
+ rb->InternalFormat = rb->_BaseFormat;
+
+ if (!screen->mesa_format_supports_render[original_format]) {
+ /* The glRenderbufferStorage paths in core Mesa detect if the driver
+ * does not support the user-requested format, and then searches for
+ * a fallback format. The DRI code bypasses core Mesa, though. So we do
+ * the fallbacks here.
+ *
+ * We must support MESA_FORMAT_R8G8B8X8 on Android because the Android
+ * framework requires HAL_PIXEL_FORMAT_RGBX8888 winsys surfaces.
+ */
+ format = _mesa_format_fallback_rgbx_to_rgba(original_format);
+ assert(screen->mesa_format_supports_render[format]);
+ }
+ return format;
+}
+
static void
intel_image_target_renderbuffer_storage(struct gl_context *ctx,
struct gl_renderbuffer *rb,
return;
}
+ rb->Format = fallback_rgbx_to_rgba(brw->screen, rb, image->format);
+
+ mesa_format chosen_format = rb->Format == image->format ?
+ image->format : rb->Format;
+
/* __DRIimage is opaque to the core so it has to be checked here */
- if (!brw->mesa_format_supports_render[image->format]) {
+ if (!brw->mesa_format_supports_render[chosen_format]) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glEGLImageTargetRenderbufferStorage(unsupported image format)");
return;
* content.
*/
irb->mt = intel_miptree_create_for_dri_image(brw, image, GL_TEXTURE_2D,
- image->format, false);
+ rb->Format, false);
if (!irb->mt)
return;
- rb->InternalFormat = image->internal_format;
rb->Width = image->width;
rb->Height = image->height;
- rb->Format = image->format;
- rb->_BaseFormat = _mesa_get_format_base_format(image->format);
rb->NeedsFinishRenderTexture = true;
irb->layer_count = 1;
}
_mesa_init_renderbuffer(rb, 0);
rb->ClassID = INTEL_RB_CLASS;
rb->NumSamples = num_samples;
+ rb->NumStorageSamples = num_samples;
- /* The base format and internal format must be derived from the user-visible
- * format (that is, the gl_config's format), even if we internally use
- * choose a different format for the renderbuffer. Otherwise, rendering may
- * use incorrect channel write masks.
- */
- rb->_BaseFormat = _mesa_get_format_base_format(format);
- rb->InternalFormat = rb->_BaseFormat;
-
- rb->Format = format;
- if (!screen->mesa_format_supports_render[rb->Format]) {
- /* The glRenderbufferStorage paths in core Mesa detect if the driver
- * does not support the user-requested format, and then searches for
- * a falback format. The DRI code bypasses core Mesa, though. So we do
- * the fallbacks here.
- *
- * We must support MESA_FORMAT_R8G8B8X8 on Android because the Android
- * framework requires HAL_PIXEL_FORMAT_RGBX8888 winsys surfaces.
- */
- rb->Format = _mesa_format_fallback_rgbx_to_rgba(rb->Format);
- assert(screen->mesa_format_supports_render[rb->Format]);
- }
+ rb->Format = fallback_rgbx_to_rgba(screen, rb, format);
/* intel-specific methods */
rb->Delete = intel_delete_renderbuffer;
}
-#define fbo_incomplete(fb, ...) do { \
+#define fbo_incomplete(fb, error_id, ...) do { \
static GLuint msg_id = 0; \
if (unlikely(ctx->Const.ContextFlags & GL_CONTEXT_FLAG_DEBUG_BIT)) { \
- _mesa_gl_debug(ctx, &msg_id, \
- MESA_DEBUG_SOURCE_API, \
- MESA_DEBUG_TYPE_OTHER, \
- MESA_DEBUG_SEVERITY_MEDIUM, \
- __VA_ARGS__); \
+ _mesa_gl_debugf(ctx, &msg_id, \
+ MESA_DEBUG_SOURCE_API, \
+ MESA_DEBUG_TYPE_OTHER, \
+ MESA_DEBUG_SEVERITY_MEDIUM, \
+ __VA_ARGS__); \
} \
DBG(__VA_ARGS__); \
- fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED; \
+ fb->_Status = error_id; \
} while (0)
/**
d_depth != s_depth ||
depthRb->mt_level != stencilRb->mt_level ||
depthRb->mt_layer != stencilRb->mt_layer) {
- fbo_incomplete(fb,
+ fbo_incomplete(fb, GL_FRAMEBUFFER_UNSUPPORTED,
"FBO incomplete: depth and stencil must match in"
"width, height, depth, LOD and layer\n");
}
*/
if (depthRb->mt_level != stencilRb->mt_level ||
depthRb->mt_layer != stencilRb->mt_layer) {
- fbo_incomplete(fb,
+ fbo_incomplete(fb, GL_FRAMEBUFFER_UNSUPPORTED,
"FBO incomplete: depth image level/layer %d/%d != "
"stencil image %d/%d\n",
depthRb->mt_level,
}
} else {
if (!brw->has_separate_stencil) {
- fbo_incomplete(fb, "FBO incomplete: separate stencil "
- "unsupported\n");
+ fbo_incomplete(fb, GL_FRAMEBUFFER_UNSUPPORTED,
+ "FBO incomplete: separate stencil unsupported\n");
}
if (stencil_mt->format != MESA_FORMAT_S_UINT8) {
- fbo_incomplete(fb, "FBO incomplete: separate stencil is %s "
- "instead of S8\n",
- _mesa_get_format_name(stencil_mt->format));
+ fbo_incomplete(fb, GL_FRAMEBUFFER_UNSUPPORTED,
+ "FBO incomplete: separate stencil is %s "
+ "instead of S8\n",
+ _mesa_get_format_name(stencil_mt->format));
}
if (devinfo->gen < 7 && !intel_renderbuffer_has_hiz(depthRb)) {
/* Before Gen7, separate depth and stencil buffers can be used
* [DevSNB]: This field must be set to the same value (enabled
* or disabled) as Hierarchical Depth Buffer Enable.
*/
- fbo_incomplete(fb, "FBO incomplete: separate stencil "
- "without HiZ\n");
+ fbo_incomplete(fb, GL_FRAMEBUFFER_UNSUPPORTED,
+ "FBO incomplete: separate stencil without HiZ\n");
}
}
}
*/
rb = fb->Attachment[i].Renderbuffer;
if (rb == NULL) {
- fbo_incomplete(fb, "FBO incomplete: attachment without "
- "renderbuffer\n");
+ fbo_incomplete(fb, GL_FRAMEBUFFER_UNSUPPORTED,
+ "FBO incomplete: attachment without "
+ "renderbuffer\n");
continue;
}
if (fb->Attachment[i].Type == GL_TEXTURE) {
if (rb->TexImage->Border) {
- fbo_incomplete(fb, "FBO incomplete: texture with border\n");
+ fbo_incomplete(fb, GL_FRAMEBUFFER_UNSUPPORTED,
+ "FBO incomplete: texture with border\n");
continue;
}
}
irb = intel_renderbuffer(rb);
if (irb == NULL) {
- fbo_incomplete(fb, "FBO incomplete: software rendering "
- "renderbuffer\n");
+ fbo_incomplete(fb, GL_FRAMEBUFFER_UNSUPPORTED,
+ "FBO incomplete: software rendering renderbuffer\n");
continue;
}
+ if (rb->Format == MESA_FORMAT_R_SRGB8) {
+ fbo_incomplete(fb, GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT,
+ "FBO incomplete: Format not color renderable: %s\n",
+ _mesa_get_format_name(rb->Format));
+ continue;
+ }
+
if (!brw_render_target_supported(brw, rb)) {
- fbo_incomplete(fb, "FBO incomplete: Unsupported HW "
- "texture/renderbuffer format attached: %s\n",
- _mesa_get_format_name(intel_rb_format(irb)));
+ fbo_incomplete(fb, GL_FRAMEBUFFER_UNSUPPORTED,
+ "FBO incomplete: Unsupported HW "
+ "texture/renderbuffer format attached: %s\n",
+ _mesa_get_format_name(intel_rb_format(irb)));
}
}
}
}
if (ctx->Color.sRGBEnabled &&
- _mesa_get_format_color_encoding(src_irb->mt->format) !=
- _mesa_get_format_color_encoding(dst_irb->mt->format)) {
+ _mesa_is_format_srgb(src_irb->mt->format) !=
+ _mesa_is_format_srgb(dst_irb->mt->format)) {
perf_debug("glBlitFramebuffer() with sRGB conversion cannot be "
"handled by BLT path.\n");
return mask;
if (!intel_miptree_blit(brw,
src_irb->mt,
src_irb->mt_level, src_irb->mt_layer,
- srcX0, srcY0, src_rb->Name == 0,
+ srcX0, srcY0, readFb->FlipY,
dst_irb->mt,
dst_irb->mt_level, dst_irb->mt_layer,
- dstX0, dstY0, dst_rb->Name == 0,
- dstX1 - dstX0, dstY1 - dstY0, GL_COPY)) {
+ dstX0, dstY0, drawFb->FlipY,
+ dstX1 - dstX0, dstY1 - dstY0,
+ COLOR_LOGICOP_COPY)) {
perf_debug("glBlitFramebuffer(): unknown blit failure. "
"Falling back to software rendering.\n");
return mask;
if (mask == 0x0)
return;
+ /* brw_blorp_framebuffer should always be successful for color blits. */
+ assert(!(mask & GL_COLOR_BUFFER_BIT));
+
mask = _mesa_meta_BlitFramebuffer(ctx, readFb, drawFb,
srcX0, srcY0, srcX1, srcY1,
dstX0, dstY0, dstX1, dstY1,
assert(!"Invalid blit");
}
- /* Try using the BLT engine. */
- mask = intel_blit_framebuffer_with_blitter(ctx, readFb, drawFb,
- srcX0, srcY0, srcX1, srcY1,
- dstX0, dstY0, dstX1, dstY1,
- mask);
- if (mask == 0x0)
- return;
-
_swrast_BlitFramebuffer(ctx, readFb, drawFb,
srcX0, srcY0, srcX1, srcY1,
dstX0, dstY0, dstX1, dstY1,
void
brw_cache_sets_clear(struct brw_context *brw)
{
- struct hash_entry *render_entry;
hash_table_foreach(brw->render_cache, render_entry)
_mesa_hash_table_remove(brw->render_cache, render_entry);
- struct set_entry *depth_entry;
set_foreach(brw->depth_cache, depth_entry)
_mesa_set_remove(brw->depth_cache, depth_entry);
}