aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/mesa')
-rw-r--r--mesalib/src/mesa/Android.gen.mk16
-rw-r--r--mesalib/src/mesa/Android.libmesa_glsl_utils.mk6
-rw-r--r--mesalib/src/mesa/Makefile.am1
-rw-r--r--mesalib/src/mesa/drivers/SConscript3
-rw-r--r--mesalib/src/mesa/drivers/common/meta_blit.c6
-rw-r--r--mesalib/src/mesa/drivers/common/meta_tex_subimage.c12
-rw-r--r--mesalib/src/mesa/drivers/dri/Makefile.am1
-rw-r--r--mesalib/src/mesa/drivers/dri/common/Android.mk8
-rw-r--r--mesalib/src/mesa/drivers/dri/common/Makefile.am6
-rw-r--r--mesalib/src/mesa/drivers/dri/common/Makefile.sources4
-rw-r--r--mesalib/src/mesa/drivers/dri/common/SConscript2
-rw-r--r--mesalib/src/mesa/drivers/dri/common/dri_util.c22
-rw-r--r--mesalib/src/mesa/drivers/dri/swrast/swrast.c4
-rw-r--r--mesalib/src/mesa/drivers/haiku/swrast/SConscript33
-rw-r--r--mesalib/src/mesa/drivers/haiku/swrast/SoftwareRast.cpp697
-rw-r--r--mesalib/src/mesa/drivers/haiku/swrast/SoftwareRast.h95
-rw-r--r--mesalib/src/mesa/drivers/haiku/swrast/SoftwareRast.rdef39
-rw-r--r--mesalib/src/mesa/main/api_exec.h3
-rw-r--r--mesalib/src/mesa/main/api_loopback.c2
-rw-r--r--mesalib/src/mesa/main/arrayobj.c22
-rw-r--r--mesalib/src/mesa/main/attrib.c22
-rw-r--r--mesalib/src/mesa/main/blit.c7
-rw-r--r--mesalib/src/mesa/main/bufferobj.c105
-rw-r--r--mesalib/src/mesa/main/buffers.c21
-rw-r--r--mesalib/src/mesa/main/clear.c32
-rw-r--r--mesalib/src/mesa/main/config.h13
-rw-r--r--mesalib/src/mesa/main/context.c73
-rw-r--r--mesalib/src/mesa/main/copyimage.c39
-rw-r--r--mesalib/src/mesa/main/depth.c6
-rw-r--r--mesalib/src/mesa/main/dlist.c30
-rw-r--r--mesalib/src/mesa/main/errors.c1
-rw-r--r--mesalib/src/mesa/main/extensions.c2
-rw-r--r--mesalib/src/mesa/main/fbobject.c103
-rw-r--r--mesalib/src/mesa/main/formats.c11
-rw-r--r--mesalib/src/mesa/main/genmipmap.c7
-rw-r--r--mesalib/src/mesa/main/get.c12
-rw-r--r--mesalib/src/mesa/main/get_hash_params.py8
-rw-r--r--mesalib/src/mesa/main/getstring.c16
-rw-r--r--mesalib/src/mesa/main/glformats.c43
-rw-r--r--mesalib/src/mesa/main/glformats.h2
-rw-r--r--mesalib/src/mesa/main/glheader.h6
-rw-r--r--mesalib/src/mesa/main/hash.c28
-rw-r--r--mesalib/src/mesa/main/hash.h3
-rw-r--r--mesalib/src/mesa/main/mtypes.h14
-rw-r--r--mesalib/src/mesa/main/pipelineobj.c6
-rw-r--r--mesalib/src/mesa/main/program_resource.c6
-rw-r--r--mesalib/src/mesa/main/queryobj.c7
-rw-r--r--mesalib/src/mesa/main/readpix.c25
-rw-r--r--mesalib/src/mesa/main/readpix.h3
-rw-r--r--mesalib/src/mesa/main/samplerobj.c7
-rw-r--r--mesalib/src/mesa/main/shader_query.cpp25
-rw-r--r--mesalib/src/mesa/main/shaderapi.c6
-rw-r--r--mesalib/src/mesa/main/shaderobj.c4
-rw-r--r--mesalib/src/mesa/main/shared.c1
-rw-r--r--mesalib/src/mesa/main/state.c2
-rw-r--r--mesalib/src/mesa/main/texgetimage.c14
-rw-r--r--mesalib/src/mesa/main/teximage.c76
-rw-r--r--mesalib/src/mesa/main/texobj.c14
-rw-r--r--mesalib/src/mesa/main/texparam.c84
-rw-r--r--mesalib/src/mesa/main/texstorage.c7
-rw-r--r--mesalib/src/mesa/main/textureview.c95
-rw-r--r--mesalib/src/mesa/main/textureview.h9
-rw-r--r--mesalib/src/mesa/main/transformfeedback.c42
-rw-r--r--mesalib/src/mesa/main/uniform_query.cpp15
-rw-r--r--mesalib/src/mesa/main/uniforms.h4
-rw-r--r--mesalib/src/mesa/main/varray.c64
-rw-r--r--mesalib/src/mesa/main/version.c75
-rw-r--r--mesalib/src/mesa/main/version.h3
-rw-r--r--mesalib/src/mesa/main/vtxfmt.c2
-rw-r--r--mesalib/src/mesa/program/dummy_errors.c30
-rw-r--r--mesalib/src/mesa/program/ir_to_mesa.cpp20
-rw-r--r--mesalib/src/mesa/program/prog_execute.c2
-rw-r--r--mesalib/src/mesa/program/prog_instruction.c12
-rw-r--r--mesalib/src/mesa/program/prog_instruction.h33
-rw-r--r--mesalib/src/mesa/program/prog_optimize.c4
-rw-r--r--mesalib/src/mesa/program/prog_print.c8
-rw-r--r--mesalib/src/mesa/program/prog_to_nir.c108
-rw-r--r--mesalib/src/mesa/program/program.c24
-rw-r--r--mesalib/src/mesa/program/program_parse.y8
-rw-r--r--mesalib/src/mesa/program/program_parse_extra.c4
-rw-r--r--mesalib/src/mesa/program/programopt.c6
-rw-r--r--mesalib/src/mesa/state_tracker/st_atom_shader.c2
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_bitmap.c8
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_blit.c4
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_clear.c6
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_drawpixels.c8
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_drawtex.c6
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_program.c8
-rw-r--r--mesalib/src/mesa/state_tracker/st_context.c6
-rw-r--r--mesalib/src/mesa/state_tracker/st_draw.c2
-rw-r--r--mesalib/src/mesa/state_tracker/st_extensions.c6
-rw-r--r--mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp829
-rw-r--r--mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.h2
-rw-r--r--mesalib/src/mesa/state_tracker/st_manager.c3
-rw-r--r--mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c9
-rw-r--r--mesalib/src/mesa/state_tracker/st_program.c24
-rw-r--r--mesalib/src/mesa/state_tracker/st_program.h1
-rw-r--r--mesalib/src/mesa/tnl/t_context.c1
-rw-r--r--mesalib/src/mesa/vbo/vbo_exec_array.c5
99 files changed, 1186 insertions, 2185 deletions
diff --git a/mesalib/src/mesa/Android.gen.mk b/mesalib/src/mesa/Android.gen.mk
index cc979547e..145f2594c 100644
--- a/mesalib/src/mesa/Android.gen.mk
+++ b/mesalib/src/mesa/Android.gen.mk
@@ -115,9 +115,11 @@ $(intermediates)/main/api_exec.c: $(dispatch_deps)
GET_HASH_GEN := $(LOCAL_PATH)/main/get_hash_generator.py
+$(intermediates)/main/get_hash.h: PRIVATE_SCRIPT := $(MESA_PYTHON2) $(GET_HASH_GEN)
+$(intermediates)/main/get_hash.h: PRIVATE_XML := -f $(glapi)/gl_and_es_API.xml
$(intermediates)/main/get_hash.h: $(glapi)/gl_and_es_API.xml \
$(LOCAL_PATH)/main/get_hash_params.py $(GET_HASH_GEN)
- @$(MESA_PYTHON2) $(GET_HASH_GEN) -f $< > $@
+ $(call es-gen)
FORMAT_INFO := $(LOCAL_PATH)/main/format_info.py
format_info_deps := \
@@ -125,8 +127,10 @@ format_info_deps := \
$(LOCAL_PATH)/main/format_parser.py \
$(FORMAT_INFO)
+$(intermediates)/main/format_info.h: PRIVATE_SCRIPT := $(MESA_PYTHON2) $(FORMAT_INFO)
+$(intermediates)/main/format_info.h: PRIVATE_XML :=
$(intermediates)/main/format_info.h: $(format_info_deps)
- @$(MESA_PYTHON2) $(FORMAT_INFO) $< > $@
+ $(call es-gen, $<)
FORMAT_PACK := $(LOCAL_PATH)/main/format_pack.py
format_pack_deps := \
@@ -134,8 +138,10 @@ format_pack_deps := \
$(LOCAL_PATH)/main/format_parser.py \
$(FORMAT_PACK)
+$(intermediates)/main/format_pack.c: PRIVATE_SCRIPT := $(MESA_PYTHON2) $(FORMAT_PACK)
+$(intermediates)/main/format_pack.c: PRIVATE_XML :=
$(intermediates)/main/format_pack.c: $(format_pack_deps)
- $(hide) $(MESA_PYTHON2) $(FORMAT_PACK) $< > $@
+ $(call es-gen, $<)
FORMAT_UNPACK := $(LOCAL_PATH)/main/format_unpack.py
format_unpack_deps := \
@@ -143,5 +149,7 @@ format_unpack_deps := \
$(LOCAL_PATH)/main/format_parser.py \
$(FORMAT_UNPACK)
+$(intermediates)/main/format_unpack.c: PRIVATE_SCRIPT := $(MESA_PYTHON2) $(FORMAT_UNPACK)
+$(intermediates)/main/format_unpack.c: PRIVATE_XML :=
$(intermediates)/main/format_unpack.c: $(format_unpack_deps)
- $(hide) $(MESA_PYTHON2) $(FORMAT_UNPACK) $< > $@
+ $(call es-gen, $<)
diff --git a/mesalib/src/mesa/Android.libmesa_glsl_utils.mk b/mesalib/src/mesa/Android.libmesa_glsl_utils.mk
index 3497377af..ed620ac64 100644
--- a/mesalib/src/mesa/Android.libmesa_glsl_utils.mk
+++ b/mesalib/src/mesa/Android.libmesa_glsl_utils.mk
@@ -44,7 +44,8 @@ LOCAL_C_INCLUDES := \
LOCAL_SRC_FILES := \
main/imports.c \
program/prog_hash_table.c \
- program/symbol_table.c
+ program/symbol_table.c \
+ program/dummy_errors.c
include $(MESA_COMMON_MK)
include $(BUILD_STATIC_LIBRARY)
@@ -68,7 +69,8 @@ LOCAL_C_INCLUDES := \
LOCAL_SRC_FILES := \
main/imports.c \
program/prog_hash_table.c \
- program/symbol_table.c
+ program/symbol_table.c \
+ program/dummy_errors.c
include $(MESA_COMMON_MK)
include $(BUILD_HOST_STATIC_LIBRARY)
diff --git a/mesalib/src/mesa/Makefile.am b/mesalib/src/mesa/Makefile.am
index 60114e4f6..71794b5da 100644
--- a/mesalib/src/mesa/Makefile.am
+++ b/mesalib/src/mesa/Makefile.am
@@ -60,7 +60,6 @@ main/git_sha1.h: main/git_sha1.h.tmp
include Makefile.sources
EXTRA_DIST = \
- drivers/haiku \
drivers/SConscript \
main/format_info.py \
main/format_pack.py \
diff --git a/mesalib/src/mesa/drivers/SConscript b/mesalib/src/mesa/drivers/SConscript
index db656780c..5d654f538 100644
--- a/mesalib/src/mesa/drivers/SConscript
+++ b/mesalib/src/mesa/drivers/SConscript
@@ -8,6 +8,3 @@ if env['dri']:
'dri/common/xmlpool/SConscript',
'dri/common/SConscript',
])
-
-if env['platform'] == 'haiku':
- SConscript('haiku/swrast/SConscript')
diff --git a/mesalib/src/mesa/drivers/common/meta_blit.c b/mesalib/src/mesa/drivers/common/meta_blit.c
index bb2164276..9cace2b24 100644
--- a/mesalib/src/mesa/drivers/common/meta_blit.c
+++ b/mesalib/src/mesa/drivers/common/meta_blit.c
@@ -82,7 +82,7 @@ setup_glsl_msaa_blit_scaled_shader(struct gl_context *ctx,
y_scale = samples * 0.5;
/* We expect only power of 2 samples in source multisample buffer. */
- assert(samples > 0 && (samples & (samples - 1)) == 0);
+ assert(samples > 0 && is_power_of_two(samples));
while (samples >> (shader_offset + 1)) {
shader_offset++;
}
@@ -263,7 +263,7 @@ setup_glsl_msaa_blit_shader(struct gl_context *ctx,
}
/* We expect only power of 2 samples in source multisample buffer. */
- assert(samples > 0 && (samples & (samples - 1)) == 0);
+ assert(samples > 0 && is_power_of_two(samples));
while (samples >> (shader_offset + 1)) {
shader_offset++;
}
@@ -434,7 +434,7 @@ setup_glsl_msaa_blit_shader(struct gl_context *ctx,
* (so the floating point exponent just gets increased), rather than
* doing a naive sum and dividing.
*/
- assert((samples & (samples - 1)) == 0);
+ assert(is_power_of_two(samples));
/* Fetch each individual sample. */
sample_resolve = rzalloc_size(mem_ctx, 1);
for (i = 0; i < samples; i++) {
diff --git a/mesalib/src/mesa/drivers/common/meta_tex_subimage.c b/mesalib/src/mesa/drivers/common/meta_tex_subimage.c
index ad6e7873e..d2474f527 100644
--- a/mesalib/src/mesa/drivers/common/meta_tex_subimage.c
+++ b/mesalib/src/mesa/drivers/common/meta_tex_subimage.c
@@ -34,6 +34,7 @@
#include "macros.h"
#include "meta.h"
#include "pbo.h"
+#include "readpix.h"
#include "shaderapi.h"
#include "state.h"
#include "teximage.h"
@@ -150,7 +151,8 @@ _mesa_meta_pbo_TexSubImage(struct gl_context *ctx, GLuint dims,
bool success = false;
int z;
- if (!_mesa_is_bufferobj(packing->BufferObj) && !create_pbo)
+ if (!_mesa_is_bufferobj(packing->BufferObj) &&
+ (!create_pbo || pixels == NULL))
return false;
if (format == GL_DEPTH_COMPONENT ||
@@ -257,6 +259,7 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, GLuint dims,
GLuint pbo = 0, pbo_tex = 0, fbos[2] = { 0, 0 };
int full_height, image_height;
struct gl_texture_image *pbo_tex_image;
+ struct gl_renderbuffer *rb = NULL;
GLenum status;
bool success = false;
int z;
@@ -273,6 +276,13 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, GLuint dims,
if (ctx->_ImageTransferState)
return false;
+
+ if (!tex_image) {
+ rb = ctx->ReadBuffer->_ColorReadBuffer;
+ if (_mesa_need_rgb_to_luminance_conversion(rb->Format, format))
+ return false;
+ }
+
/* For arrays, use a tall (height * depth) 2D texture but taking into
* account the inter-image padding specified with the image height packing
* property.
diff --git a/mesalib/src/mesa/drivers/dri/Makefile.am b/mesalib/src/mesa/drivers/dri/Makefile.am
index fa1de103b..08a8e6455 100644
--- a/mesalib/src/mesa/drivers/dri/Makefile.am
+++ b/mesalib/src/mesa/drivers/dri/Makefile.am
@@ -60,6 +60,7 @@ mesa_dri_drivers_la_LIBADD = \
../../libmesa.la \
common/libmegadriver_stub.la \
common/libdricommon.la \
+ common/libxmlconfig.la \
$(MEGADRIVERS_DEPS) \
$(DRI_LIB_DEPS) \
$()
diff --git a/mesalib/src/mesa/drivers/dri/common/Android.mk b/mesalib/src/mesa/drivers/dri/common/Android.mk
index a7fcd6d57..6986f5e8c 100644
--- a/mesalib/src/mesa/drivers/dri/common/Android.mk
+++ b/mesalib/src/mesa/drivers/dri/common/Android.mk
@@ -39,7 +39,9 @@ intermediates := $(call local-generated-sources-dir)
LOCAL_C_INCLUDES := \
$(MESA_DRI_C_INCLUDES)
-LOCAL_EXPORT_C_INCLUDE_DIRS := $(intermediates)
+LOCAL_EXPORT_C_INCLUDE_DIRS := \
+ $(LOCAL_PATH) \
+ $(intermediates)
# swrast only
ifeq ($(MESA_GPU_DRIVERS),swrast)
@@ -48,7 +50,9 @@ else
LOCAL_SHARED_LIBRARIES := libdrm
endif
-LOCAL_SRC_FILES := $(DRI_COMMON_FILES)
+LOCAL_SRC_FILES := \
+ $(DRI_COMMON_FILES) \
+ $(XMLCONFIG_FILES)
MESA_DRI_OPTIONS_H := $(intermediates)/xmlpool/options.h
LOCAL_GENERATED_SOURCES := $(MESA_DRI_OPTIONS_H)
diff --git a/mesalib/src/mesa/drivers/dri/common/Makefile.am b/mesalib/src/mesa/drivers/dri/common/Makefile.am
index da8f97a98..ae19fcb35 100644
--- a/mesalib/src/mesa/drivers/dri/common/Makefile.am
+++ b/mesalib/src/mesa/drivers/dri/common/Makefile.am
@@ -33,16 +33,20 @@ AM_CFLAGS = \
-I$(top_srcdir)/src/gallium/include \
-I$(top_srcdir)/src/gallium/auxiliary \
$(DEFINES) \
- $(EXPAT_CFLAGS) \
$(VISIBILITY_CFLAGS)
noinst_LTLIBRARIES = \
libdricommon.la \
+ libxmlconfig.la \
libmegadriver_stub.la \
libdri_test_stubs.la
libdricommon_la_SOURCES = $(DRI_COMMON_FILES)
+libxmlconfig_la_SOURCES = $(XMLCONFIG_FILES)
+libxmlconfig_la_CFLAGS = $(AM_CFLAGS) $(EXPAT_CFLAGS)
+libxmlconfig_la_LIBADD = $(EXPAT_LIBS) -lm
+
libdri_test_stubs_la_SOURCES = $(test_stubs_FILES)
libdri_test_stubs_la_CFLAGS = $(AM_CFLAGS) -DNO_MAIN
diff --git a/mesalib/src/mesa/drivers/dri/common/Makefile.sources b/mesalib/src/mesa/drivers/dri/common/Makefile.sources
index d00ec5f73..d5d8da8fc 100644
--- a/mesalib/src/mesa/drivers/dri/common/Makefile.sources
+++ b/mesalib/src/mesa/drivers/dri/common/Makefile.sources
@@ -2,7 +2,9 @@ DRI_COMMON_FILES := \
utils.c \
utils.h \
dri_util.c \
- dri_util.h \
+ dri_util.h
+
+XMLCONFIG_FILES := \
xmlconfig.c \
xmlconfig.h
diff --git a/mesalib/src/mesa/drivers/dri/common/SConscript b/mesalib/src/mesa/drivers/dri/common/SConscript
index 0bee1b41f..b402736db 100644
--- a/mesalib/src/mesa/drivers/dri/common/SConscript
+++ b/mesalib/src/mesa/drivers/dri/common/SConscript
@@ -37,7 +37,7 @@ drienv.PkgUseModules('DRM')
# else
#env.Append(CPPDEFINES = ['__NOT_HAVE_DRM_H'])
-sources = drienv.ParseSourceList('Makefile.sources', 'DRI_COMMON_FILES')
+sources = drienv.ParseSourceList('Makefile.sources', ['DRI_COMMON_FILES', 'XMLCONFIG_FILES' ])
dri_common = drienv.ConvenienceLibrary(
target = 'dri_common',
diff --git a/mesalib/src/mesa/drivers/dri/common/dri_util.c b/mesalib/src/mesa/drivers/dri/common/dri_util.c
index d6e875fcf..e7ababe0b 100644
--- a/mesalib/src/mesa/drivers/dri/common/dri_util.c
+++ b/mesalib/src/mesa/drivers/dri/common/dri_util.c
@@ -162,13 +162,21 @@ driCreateNewScreen2(int scrn, int fd,
return NULL;
}
- int gl_version_override = _mesa_get_gl_version_override();
- if (gl_version_override >= 31) {
- psp->max_gl_core_version = MAX2(psp->max_gl_core_version,
- gl_version_override);
- } else {
- psp->max_gl_compat_version = MAX2(psp->max_gl_compat_version,
- gl_version_override);
+ struct gl_constants consts = { 0 };
+ gl_api api;
+ unsigned version;
+
+ api = API_OPENGLES2;
+ if (_mesa_override_gl_version_contextless(&consts, &api, &version))
+ psp->max_gl_es2_version = version;
+
+ api = API_OPENGL_COMPAT;
+ if (_mesa_override_gl_version_contextless(&consts, &api, &version)) {
+ if (api == API_OPENGL_CORE) {
+ psp->max_gl_core_version = version;
+ } else {
+ psp->max_gl_compat_version = version;
+ }
}
psp->api_mask = (1 << __DRI_API_OPENGL);
diff --git a/mesalib/src/mesa/drivers/dri/swrast/swrast.c b/mesalib/src/mesa/drivers/dri/swrast/swrast.c
index cbc946c3f..2d4bb702f 100644
--- a/mesalib/src/mesa/drivers/dri/swrast/swrast.c
+++ b/mesalib/src/mesa/drivers/dri/swrast/swrast.c
@@ -62,7 +62,9 @@
#include "swrast/s_context.h"
#include <sys/types.h>
-#include <sys/sysctl.h>
+#ifdef HAVE_SYS_SYSCTL_H
+# include <sys/sysctl.h>
+#endif
const __DRIextension **__driDriverGetExtensions_swrast(void);
diff --git a/mesalib/src/mesa/drivers/haiku/swrast/SConscript b/mesalib/src/mesa/drivers/haiku/swrast/SConscript
deleted file mode 100644
index 907325e32..000000000
--- a/mesalib/src/mesa/drivers/haiku/swrast/SConscript
+++ /dev/null
@@ -1,33 +0,0 @@
-Import('*')
-
-env = env.Clone()
-
-env.Append(CPPPATH = [
- '#/src',
- '#/src/mapi',
- '#/src/mesa',
- '#/src/mesa/main',
- '#/include/HaikuGL',
- '/boot/system/develop/headers/private',
- Dir('../../../mapi'), # src/mapi build path for python-generated GL API files/headers
-])
-
-env.Prepend(LIBS = [
- mesautil,
- glsl,
- mesa,
-])
-
-env.Prepend(LIBS = [libgl])
-
-sources = [
- 'SoftwareRast.cpp'
-]
-
-# Disallow undefined symbols
-#env.Append(SHLINKFLAGS = ['-Wl,-z,defs'])
-
-libswrast = env.SharedLibrary(
- target = 'swrast',
- source = sources
-)
diff --git a/mesalib/src/mesa/drivers/haiku/swrast/SoftwareRast.cpp b/mesalib/src/mesa/drivers/haiku/swrast/SoftwareRast.cpp
deleted file mode 100644
index 813ad1ff2..000000000
--- a/mesalib/src/mesa/drivers/haiku/swrast/SoftwareRast.cpp
+++ /dev/null
@@ -1,697 +0,0 @@
-/*
- * Copyright 2006-2012, Haiku, Inc. All rights reserved.
- * Distributed under the terms of the MIT License.
- *
- * Authors:
- * Jérôme Duval, korli@users.berlios.de
- * Philippe Houdoin, philippe.houdoin@free.fr
- * Artur Wyszynski, harakash@gmail.com
- * Alexander von Gluck, kallisti5@unixzen.com
- */
-
-
-#include <kernel/image.h>
-#include "SoftwareRast.h"
-
-#include <Autolock.h>
-#include <interface/DirectWindowPrivate.h>
-#include <GraphicsDefs.h>
-#include <Screen.h>
-#include <stdio.h>
-#include <string.h>
-
-extern "C" {
-#include "extensions.h"
-#include "drivers/common/driverfuncs.h"
-#include "drivers/common/meta.h"
-#include "main/api_exec.h"
-#include "main/colormac.h"
-#include "main/cpuinfo.h"
-#include "main/buffers.h"
-#include "main/formats.h"
-#include "main/framebuffer.h"
-#include "main/renderbuffer.h"
-#include "main/version.h"
-#include "main/vtxfmt.h"
-#include "swrast/swrast.h"
-#include "swrast/s_renderbuffer.h"
-#include "swrast_setup/swrast_setup.h"
-#include "tnl/tnl.h"
-#include "tnl/t_context.h"
-#include "tnl/t_pipeline.h"
-#include "vbo/vbo.h"
-
-
-#ifdef DEBUG
-# define TRACE(x...) printf("MesaSoftwareRast: " x)
-# define CALLED() printf("MesaSoftwareRast: %s\n", __PRETTY_FUNCTION__)
-#else
-# define TRACE(x...)
-# define CALLED()
-#endif
-
-#define ERROR(x...) printf("MesaSoftwareRast: " x)
-}
-
-
-extern const char* color_space_name(color_space space);
-
-
-extern "C" _EXPORT BGLRenderer*
-instantiate_gl_renderer(BGLView* view, ulong options,
- BGLDispatcher* dispatcher)
-{
- return new MesaSoftwareRast(view, options, dispatcher);
-}
-
-
-MesaSoftwareRast::MesaSoftwareRast(BGLView* view, ulong options,
- BGLDispatcher* dispatcher)
- : BGLRenderer(view, options, dispatcher),
- fBitmap(NULL),
- fDirectModeEnabled(false),
- fInfo(NULL),
- fInfoLocker("info locker"),
- fVisual(NULL),
- fFrameBuffer(NULL),
- fFrontRenderBuffer(NULL),
- fBackRenderBuffer(NULL),
- fColorSpace(B_NO_COLOR_SPACE)
-{
- CALLED();
-
- fColorSpace = BScreen(GLView()->Window()).ColorSpace();
-
- // We force single buffering for the time being
- options &= ~BGL_DOUBLE;
-
- const GLboolean rgbFlag = ((options & BGL_INDEX) == 0);
- const GLboolean alphaFlag = ((options & BGL_ALPHA) == BGL_ALPHA);
- const GLboolean dblFlag = ((options & BGL_DOUBLE) == BGL_DOUBLE);
- const GLboolean stereoFlag = false;
- const GLint depth = (options & BGL_DEPTH) ? 16 : 0;
- const GLint stencil = (options & BGL_STENCIL) ? 8 : 0;
- const GLint accum = (options & BGL_ACCUM) ? 16 : 0;
- const GLint red = rgbFlag ? 8 : 0;
- const GLint green = rgbFlag ? 8 : 0;
- const GLint blue = rgbFlag ? 8 : 0;
- const GLint alpha = alphaFlag ? 8 : 0;
-
- fOptions = options; // | BGL_INDIRECT;
- struct dd_function_table functions;
-
- fVisual = _mesa_create_visual(dblFlag, stereoFlag, red, green,
- blue, alpha, depth, stencil, accum, accum, accum,
- alpha ? accum : 0, 1);
-
- // Initialize device driver function table
- _mesa_init_driver_functions(&functions);
-
- functions.GetString = _GetString;
- functions.UpdateState = _UpdateState;
- functions.MapRenderbuffer = _RenderBufferMap;
- functions.Flush = _Flush;
-
- // create core context
- // We inherit gl_context to this class
- _mesa_initialize_context(this, API_OPENGL_COMPAT, fVisual, NULL,
- &functions);
-
- /* Initialize the software rasterizer and helper modules. */
- _swrast_CreateContext(this);
- _vbo_CreateContext(this);
- _tnl_CreateContext(this);
- _swsetup_CreateContext(this);
- _swsetup_Wakeup(this);
-
- // Use default TCL pipeline
- TNL_CONTEXT(this)->Driver.RunPipeline = _tnl_run_pipeline;
-
- _mesa_meta_init(this);
- _mesa_enable_sw_extensions(this);
-
- _mesa_compute_version(this);
-
- _mesa_initialize_dispatch_tables(this);
- _mesa_initialize_vbo_vtxfmt(this);
-
- // create core framebuffer
- fFrameBuffer = _mesa_create_framebuffer(fVisual);
- if (fFrameBuffer == NULL) {
- ERROR("%s: Unable to calloc GL FrameBuffer!\n", __func__);
- _mesa_destroy_visual(fVisual);
- return;
- }
-
- // Setup front render buffer
- fFrontRenderBuffer = _NewRenderBuffer(true);
- if (fFrontRenderBuffer == NULL) {
- ERROR("%s: FrontRenderBuffer is requested but unallocated!\n",
- __func__);
- _mesa_destroy_visual(fVisual);
- free(fFrameBuffer);
- return;
- }
- _mesa_add_renderbuffer(fFrameBuffer, BUFFER_FRONT_LEFT,
- &fFrontRenderBuffer->Base);
-
- // Setup back render buffer (if requested)
- if (fVisual->doubleBufferMode) {
- fBackRenderBuffer = _NewRenderBuffer(false);
- if (fBackRenderBuffer == NULL) {
- ERROR("%s: BackRenderBuffer is requested but unallocated!\n",
- __func__);
- _mesa_destroy_visual(fVisual);
- free(fFrameBuffer);
- return;
- }
- _mesa_add_renderbuffer(fFrameBuffer, BUFFER_BACK_LEFT,
- &fBackRenderBuffer->Base);
- }
-
- _swrast_add_soft_renderbuffers(fFrameBuffer, GL_FALSE,
- fVisual->haveDepthBuffer, fVisual->haveStencilBuffer,
- fVisual->haveAccumBuffer, alphaFlag, GL_FALSE);
-
- BRect bounds = view->Bounds();
- fWidth = (GLint)bounds.Width();
- fHeight = (GLint)bounds.Height();
-
- // some stupid applications (Quake2) don't even think about calling LockGL()
- // before using glGetString and its glGet*() friends...
- // so make sure there is at least a valid context.
-
- if (!_mesa_get_current_context()) {
- LockGL();
- // not needed, we don't have a looper yet: UnlockLooper();
- }
-}
-
-
-MesaSoftwareRast::~MesaSoftwareRast()
-{
- CALLED();
- _swsetup_DestroyContext(this);
- _swrast_DestroyContext(this);
- _tnl_DestroyContext(this);
- _vbo_DestroyContext(this);
- _mesa_destroy_visual(fVisual);
- _mesa_destroy_framebuffer(fFrameBuffer);
- _mesa_destroy_context(this);
-
- free(fInfo);
- free(fFrameBuffer);
-
- delete fBitmap;
-}
-
-
-void
-MesaSoftwareRast::LockGL()
-{
- CALLED();
- BGLRenderer::LockGL();
-
- _mesa_make_current(this, fFrameBuffer, fFrameBuffer);
-
- color_space colorSpace = BScreen(GLView()->Window()).ColorSpace();
-
- GLuint width = fWidth;
- GLuint height = fHeight;
-
- BAutolock lock(fInfoLocker);
- if (fDirectModeEnabled && fInfo != NULL) {
- width = fInfo->window_bounds.right
- - fInfo->window_bounds.left + 1;
- height = fInfo->window_bounds.bottom
- - fInfo->window_bounds.top + 1;
- }
-
- if (fColorSpace != colorSpace) {
- fColorSpace = colorSpace;
- _SetupRenderBuffer(&fFrontRenderBuffer->Base, fColorSpace);
- if (fVisual->doubleBufferMode)
- _SetupRenderBuffer(&fBackRenderBuffer->Base, fColorSpace);
- }
-
- _CheckResize(width, height);
-}
-
-
-void
-MesaSoftwareRast::UnlockGL()
-{
- CALLED();
- _mesa_make_current(this, NULL, NULL);
- BGLRenderer::UnlockGL();
-}
-
-
-void
-MesaSoftwareRast::SwapBuffers(bool VSync)
-{
- CALLED();
-
- if (!fBitmap)
- return;
-
- if (fVisual->doubleBufferMode)
- _mesa_notifySwapBuffers(this);
-
- if (!fDirectModeEnabled || fInfo == NULL) {
- if (GLView()->LockLooperWithTimeout(1000) == B_OK) {
- GLView()->DrawBitmap(fBitmap, B_ORIGIN);
- GLView()->UnlockLooper();
- }
- } else {
- // TODO: Here the BGLView needs to be drawlocked.
- _CopyToDirect();
- }
-
- if (VSync) {
- BScreen screen(GLView()->Window());
- screen.WaitForRetrace();
- }
-}
-
-
-void
-MesaSoftwareRast::Draw(BRect updateRect)
-{
- CALLED();
- if (fBitmap && (!fDirectModeEnabled || (fInfo == NULL)))
- GLView()->DrawBitmap(fBitmap, updateRect, updateRect);
-}
-
-
-status_t
-MesaSoftwareRast::CopyPixelsOut(BPoint location, BBitmap* bitmap)
-{
- CALLED();
- color_space scs = fBitmap->ColorSpace();
- color_space dcs = bitmap->ColorSpace();
-
- if (scs != dcs && (scs != B_RGBA32 || dcs != B_RGB32)) {
- fprintf(stderr, "CopyPixelsOut(): incompatible color space: %s != %s\n",
- color_space_name(scs),
- color_space_name(dcs));
- return B_BAD_TYPE;
- }
-
- BRect sr = fBitmap->Bounds();
- BRect dr = bitmap->Bounds();
-
- sr = sr & dr.OffsetBySelf(location);
- dr = sr.OffsetByCopy(-location.x, -location.y);
-
- uint8* ps = (uint8*)fBitmap->Bits();
- uint8* pd = (uint8*)bitmap->Bits();
- uint32* s;
- uint32* d;
- uint32 y;
- for (y = (uint32)sr.top; y <= (uint32)sr.bottom; y++) {
- s = (uint32*)(ps + y * fBitmap->BytesPerRow());
- s += (uint32)sr.left;
-
- d = (uint32*)(pd + (y + (uint32)(dr.top - sr.top))
- * bitmap->BytesPerRow());
- d += (uint32)dr.left;
-
- memcpy(d, s, dr.IntegerWidth() * 4);
- }
- return B_OK;
-}
-
-
-status_t
-MesaSoftwareRast::CopyPixelsIn(BBitmap* bitmap, BPoint location)
-{
- CALLED();
- color_space scs = bitmap->ColorSpace();
- color_space dcs = fBitmap->ColorSpace();
-
- if (scs != dcs && (dcs != B_RGBA32 || scs != B_RGB32)) {
- fprintf(stderr, "CopyPixelsIn(): incompatible color space: %s != %s\n",
- color_space_name(scs),
- color_space_name(dcs));
- return B_BAD_TYPE;
- }
-
- BRect sr = bitmap->Bounds();
- BRect dr = fBitmap->Bounds();
-
- sr = sr & dr.OffsetBySelf(location);
- dr = sr.OffsetByCopy(-location.x, -location.y);
-
- uint8* ps = (uint8*)bitmap->Bits();
- uint8* pd = (uint8*)fBitmap->Bits();
- uint32* s;
- uint32* d;
- uint32 y;
- for (y = (uint32)sr.top; y <= (uint32)sr.bottom; y++) {
- s = (uint32*)(ps + y * bitmap->BytesPerRow());
- s += (uint32)sr.left;
-
- d = (uint32*)(pd + (y + (uint32)(dr.top - sr.top))
- * fBitmap->BytesPerRow());
- d += (uint32)dr.left;
-
- memcpy(d, s, dr.IntegerWidth() * 4);
- }
- return B_OK;
-}
-
-
-void
-MesaSoftwareRast::EnableDirectMode(bool enabled)
-{
- fDirectModeEnabled = enabled;
-}
-
-
-void
-MesaSoftwareRast::DirectConnected(direct_buffer_info* info)
-{
- // TODO: I'm not sure we need to do this: BGLView already
- // keeps a local copy of the direct_buffer_info passed by
- // BDirectWindow::DirectConnected().
- BAutolock lock(fInfoLocker);
- if (info) {
- if (!fInfo) {
- fInfo = (direct_buffer_info*)malloc(DIRECT_BUFFER_INFO_AREA_SIZE);
- if (!fInfo)
- return;
- }
- memcpy(fInfo, info, DIRECT_BUFFER_INFO_AREA_SIZE);
- } else if (fInfo) {
- free(fInfo);
- fInfo = NULL;
- }
-}
-
-
-void
-MesaSoftwareRast::FrameResized(float width, float height)
-{
- BAutolock lock(fInfoLocker);
- _CheckResize((GLuint)width, (GLuint)height);
-}
-
-
-void
-MesaSoftwareRast::_CheckResize(GLuint newWidth, GLuint newHeight)
-{
- CALLED();
-
- if (fBitmap && newWidth == fWidth
- && newHeight == fHeight) {
- return;
- }
-
- _mesa_resize_framebuffer(this, fFrameBuffer, newWidth, newHeight);
- fHeight = newHeight;
- fWidth = newWidth;
-
- _AllocateBitmap();
-}
-
-
-void
-MesaSoftwareRast::_AllocateBitmap()
-{
- CALLED();
-
- // allocate new size of back buffer bitmap
- delete fBitmap;
- fBitmap = NULL;
-
- if (fWidth < 1 || fHeight < 1) {
- TRACE("%s: Cannot allocate bitmap < 1x1!\n", __func__);
- return;
- }
-
- BRect rect(0.0, 0.0, fWidth - 1, fHeight - 1);
- fBitmap = new BBitmap(rect, fColorSpace);
-
- #if 0
- // Used for platform optimized drawing
- for (uint i = 0; i < fHeight; i++) {
- fRowAddr[fHeight - i - 1] = (GLvoid *)((GLubyte *)fBitmap->Bits()
- + i * fBitmap->BytesPerRow());
- }
- #endif
-
- fFrameBuffer->Width = fWidth;
- fFrameBuffer->Height = fHeight;
- TRACE("%s: Bitmap Size: %" B_PRIu32 "\n", __func__, fBitmap->BitsLength());
-
- fFrontRenderBuffer->Buffer = (GLubyte*)fBitmap->Bits();
-}
-
-
-// #pragma mark - static
-
-
-const GLubyte*
-MesaSoftwareRast::_GetString(gl_context* ctx, GLenum name)
-{
- switch (name) {
- case GL_VENDOR:
- return (const GLubyte*) "Mesa Project";
- case GL_RENDERER:
- return (const GLubyte*) "Software Rasterizer";
- default:
- // Let core library handle all other cases
- return NULL;
- }
-}
-
-
-void
-MesaSoftwareRast::_UpdateState(gl_context* ctx, GLuint new_state)
-{
- if (!ctx)
- return;
-
- CALLED();
- _swrast_InvalidateState(ctx, new_state);
- _swsetup_InvalidateState(ctx, new_state);
- _vbo_InvalidateState(ctx, new_state);
- _tnl_InvalidateState(ctx, new_state);
-}
-
-
-GLboolean
-MesaSoftwareRast::_RenderBufferStorage(gl_context* ctx,
- struct gl_renderbuffer* render, GLenum internalFormat,
- GLuint width, GLuint height)
-{
- CALLED();
-
- render->Width = width;
- render->Height = height;
-
- struct swrast_renderbuffer *swRenderBuffer = swrast_renderbuffer(render);
-
- swRenderBuffer->RowStride = width * _mesa_get_format_bytes(render->Format);
-
- return GL_TRUE;
-}
-
-
-GLboolean
-MesaSoftwareRast::_RenderBufferStorageMalloc(gl_context* ctx,
- struct gl_renderbuffer* render, GLenum internalFormat,
- GLuint width, GLuint height)
-{
- CALLED();
-
- render->Width = width;
- render->Height = height;
-
- struct swrast_renderbuffer *swRenderBuffer = swrast_renderbuffer(render);
-
- if (swRenderBuffer != NULL) {
- free(swRenderBuffer->Buffer);
- swRenderBuffer->RowStride
- = width * _mesa_get_format_bytes(render->Format);
-
- uint32 size = swRenderBuffer->RowStride * height;
- TRACE("%s: Allocate %" B_PRIu32 " bytes for RenderBuffer\n",
- __func__, size);
- swRenderBuffer->Buffer = (GLubyte*)malloc(size);
- if (!swRenderBuffer->Buffer) {
- ERROR("%s: Memory allocation failure!\n", __func__);
- return GL_FALSE;
- }
- } else {
- ERROR("%s: Couldn't obtain software renderbuffer!\n",
- __func__);
- return GL_FALSE;
- }
-
- return GL_TRUE;
-}
-
-
-void
-MesaSoftwareRast::_Flush(gl_context* ctx)
-{
- CALLED();
- MesaSoftwareRast* driverContext = static_cast<MesaSoftwareRast*>(ctx);
-
- //MesaSoftwareRast* driverContext = (MesaSoftwareRast*)ctx->DriverCtx;
- if ((driverContext->fOptions & BGL_DOUBLE) == 0) {
- // TODO: SwapBuffers() can call _CopyToDirect(), which should
- // be always called with with the BGLView drawlocked.
- // This is not always the case if called from here.
- driverContext->SwapBuffers();
- }
-}
-
-
-struct swrast_renderbuffer*
-MesaSoftwareRast::_NewRenderBuffer(bool front)
-{
- CALLED();
- struct swrast_renderbuffer *swRenderBuffer
- = (struct swrast_renderbuffer*)calloc(1, sizeof *swRenderBuffer);
-
- if (!swRenderBuffer) {
- ERROR("%s: Failed calloc RenderBuffer\n", __func__);
- return NULL;
- }
-
- _mesa_init_renderbuffer(&swRenderBuffer->Base, 0);
-
- swRenderBuffer->Base.ClassID = HAIKU_SWRAST_RENDERBUFFER_CLASS;
- swRenderBuffer->Base.RefCount = 1;
- swRenderBuffer->Base.Delete = _RenderBufferDelete;
-
- if (!front)
- swRenderBuffer->Base.AllocStorage = _RenderBufferStorageMalloc;
- else
- swRenderBuffer->Base.AllocStorage = _RenderBufferStorage;
-
- if (_SetupRenderBuffer(&swRenderBuffer->Base, fColorSpace) != B_OK) {
- free(swRenderBuffer);
- return NULL;
- }
-
- return swRenderBuffer;
-}
-
-
-status_t
-MesaSoftwareRast::_SetupRenderBuffer(struct gl_renderbuffer* rb,
- color_space colorSpace)
-{
- CALLED();
-
- rb->InternalFormat = GL_RGBA;
-
- switch (colorSpace) {
- case B_RGBA32:
- rb->_BaseFormat = GL_RGBA;
- rb->Format = MESA_FORMAT_B8G8R8A8_UNORM;
- break;
- case B_RGB32:
- rb->_BaseFormat = GL_RGB;
- rb->Format = MESA_FORMAT_B8G8R8X8_UNORM;
- break;
- case B_RGB24:
- rb->_BaseFormat = GL_RGB;
- rb->Format = MESA_FORMAT_BGR_UNORM8;
- break;
- case B_RGB16:
- rb->_BaseFormat = GL_RGB;
- rb->Format = MESA_FORMAT_B5G6R5_UNORM;
- break;
- case B_RGB15:
- rb->_BaseFormat = GL_RGB;
- rb->Format = MESA_FORMAT_B5G5R5A1_UNORM;
- break;
- default:
- fprintf(stderr, "Unsupported screen color space %s\n",
- color_space_name(fColorSpace));
- debugger("Unsupported OpenGL color space");
- return B_ERROR;
- }
- return B_OK;
-}
-
-
-/*! Y inverted Map RenderBuffer function
- We use a BBitmap for storage which has Y inverted.
- If the Mesa provided Map function ever allows external
- control of this we can omit this function.
-*/
-void
-MesaSoftwareRast::_RenderBufferMap(gl_context *ctx,
- struct gl_renderbuffer *rb, GLuint x, GLuint y, GLuint w, GLuint h,
- GLbitfield mode, GLubyte **mapOut, GLint *rowStrideOut)
-{
- if (rb->ClassID == HAIKU_SWRAST_RENDERBUFFER_CLASS) {
- struct swrast_renderbuffer *srb = swrast_renderbuffer(rb);
- const GLuint bpp = _mesa_get_format_bytes(rb->Format);
- GLint rowStride = rb->Width * bpp; // in Bytes
-
- y = rb->Height - y - 1;
-
- *rowStrideOut = -rowStride;
- *mapOut = (GLubyte *) srb->Buffer + y * rowStride + x * bpp;
- } else {
- _swrast_map_soft_renderbuffer(ctx, rb, x, y, w, h, mode,
- mapOut, rowStrideOut);
- }
-}
-
-
-void
-MesaSoftwareRast::_RenderBufferDelete(struct gl_context *ctx,
- struct gl_renderbuffer* rb)
-{
- CALLED();
- if (rb != NULL) {
- struct swrast_renderbuffer *swRenderBuffer
- = swrast_renderbuffer(rb);
- if (swRenderBuffer != NULL)
- free(swRenderBuffer->Buffer);
- }
- free(rb);
-}
-
-
-void
-MesaSoftwareRast::_CopyToDirect()
-{
- BAutolock lock(fInfoLocker);
-
- // check the bitmap size still matches the size
- if (fInfo->window_bounds.bottom - fInfo->window_bounds.top
- != fBitmap->Bounds().IntegerHeight()
- || fInfo->window_bounds.right - fInfo->window_bounds.left
- != fBitmap->Bounds().IntegerWidth())
- return;
-
- uint8 bytesPerPixel = fInfo->bits_per_pixel / 8;
- uint32 bytesPerRow = fBitmap->BytesPerRow();
- for (uint32 i = 0; i < fInfo->clip_list_count; i++) {
- clipping_rect *clip = &fInfo->clip_list[i];
- int32 height = clip->bottom - clip->top + 1;
- int32 bytesWidth
- = (clip->right - clip->left + 1) * bytesPerPixel;
- uint8* p = (uint8*)fInfo->bits + clip->top
- * fInfo->bytes_per_row + clip->left * bytesPerPixel;
- uint8* b = (uint8*)fBitmap->Bits()
- + (clip->top - fInfo->window_bounds.top) * bytesPerRow
- + (clip->left - fInfo->window_bounds.left)
- * bytesPerPixel;
-
- for (int y = 0; y < height; y++) {
- memcpy(p, b, bytesWidth);
- p += fInfo->bytes_per_row;
- b += bytesPerRow;
- }
- }
-}
diff --git a/mesalib/src/mesa/drivers/haiku/swrast/SoftwareRast.h b/mesalib/src/mesa/drivers/haiku/swrast/SoftwareRast.h
deleted file mode 100644
index 8f0f01848..000000000
--- a/mesalib/src/mesa/drivers/haiku/swrast/SoftwareRast.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright 2006-2012, Haiku, Inc. All rights reserved.
- * Distributed under the terms of the MIT License.
- *
- * Authors:
- * Jérôme Duval, korli@users.berlios.de
- * Philippe Houdoin, philippe.houdoin@free.fr
- * Artur Wyszynski, harakash@gmail.com
- */
-#ifndef MESASOFTWARERENDERER_H
-#define MESASOFTWARERENDERER_H
-
-
-#define HAIKU_SWRAST_RENDERBUFFER_CLASS 0x737752 // swR
-
-
-#include "GLRenderer.h"
-
-extern "C" {
-#include "context.h"
-#include "main/version.h"
-#include "swrast/s_chan.h"
-#include "swrast/s_context.h"
-}
-
-
-class MesaSoftwareRast : public BGLRenderer, public gl_context {
-public:
- MesaSoftwareRast(BGLView* view,
- ulong bgl_options,
- BGLDispatcher* dispatcher);
- virtual ~MesaSoftwareRast();
-
- virtual void LockGL();
- virtual void UnlockGL();
-
- virtual void SwapBuffers(bool VSync = false);
- virtual void Draw(BRect updateRect);
- virtual status_t CopyPixelsOut(BPoint source, BBitmap* dest);
- virtual status_t CopyPixelsIn(BBitmap* source, BPoint dest);
- virtual void FrameResized(float width, float height);
-
- virtual void EnableDirectMode(bool enabled);
- virtual void DirectConnected(direct_buffer_info* info);
-
-private:
- static const GLubyte* _GetString(gl_context* ctx, GLenum name);
- void _CheckResize(GLuint newWidth, GLuint newHeight);
- static void _UpdateState(gl_context* ctx, GLuint newState);
- static void _Flush(gl_context *ctx);
-
- struct swrast_renderbuffer* _NewRenderBuffer(bool front);
- status_t _SetupRenderBuffer(struct gl_renderbuffer* rb,
- color_space colorSpace);
-
-/* Mesa callbacks */
- static void _RenderBufferDelete(struct gl_context *ctx,
- struct gl_renderbuffer* rb);
- static GLboolean _RenderBufferStorage(gl_context* ctx,
- struct gl_renderbuffer* render,
- GLenum internalFormat,
- GLuint width, GLuint height);
- static GLboolean _RenderBufferStorageMalloc(gl_context* ctx,
- struct gl_renderbuffer* render,
- GLenum internalFormat,
- GLuint width, GLuint height);
- static void _RenderBufferMap(gl_context *ctx,
- struct gl_renderbuffer *rb,
- GLuint x, GLuint y, GLuint w, GLuint h,
- GLbitfield mode, GLubyte **mapOut,
- GLint *rowStrideOut);
-
- void _AllocateBitmap();
- void _CopyToDirect();
-
- BBitmap* fBitmap;
- bool fDirectModeEnabled;
- direct_buffer_info* fInfo;
- BLocker fInfoLocker;
- ulong fOptions;
-
- gl_config* fVisual;
-
- struct gl_framebuffer* fFrameBuffer;
- struct swrast_renderbuffer* fFrontRenderBuffer;
- struct swrast_renderbuffer* fBackRenderBuffer;
-
- GLuint fWidth;
- GLuint fHeight;
- color_space fColorSpace;
-
- void* fRowAddr[SWRAST_MAX_HEIGHT];
-};
-
-#endif // MESASOFTWARERENDERER_H
diff --git a/mesalib/src/mesa/drivers/haiku/swrast/SoftwareRast.rdef b/mesalib/src/mesa/drivers/haiku/swrast/SoftwareRast.rdef
deleted file mode 100644
index cb6033210..000000000
--- a/mesalib/src/mesa/drivers/haiku/swrast/SoftwareRast.rdef
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2012, Haiku, Inc. All rights reserved.
- * Distributed under the terms of the MIT License.
- */
-
-resource app_signature "application/x-vnd.Haiku-swrast";
-
-resource app_version {
- major = 9,
- middle = 0,
- minor = 0,
- variety = 0,
- internal = 0,
- short_info = "Software Rasterizer",
- long_info = "Haiku Mesa Software GL Rasterizer"
-};
-
-resource vector_icon {
- $"6E6369660A0200140294A9FF18020014028DFFFF97058C0500020006023B10B7"
- $"37F036BA1A993D466848C719BEBE2000919292FFD5D5D5020016023900000000"
- $"000000003EE0004AE00048E0005EF884C702000203392E8D383001BAD97F3C12"
- $"8B4786BD48B8AD0D97BBFFFF7B4168DBE9FF4168DB97020002023A0C1238D099"
- $"BE44203F4BD14B38844678240DF56A7D9FE1EA064CC704016B0500090A044024"
- $"2438404C5C380A044028243C40505C3C0A042438243B5C3C5C380608BFBE4D59"
- $"4D59515957575659585560406044603C5E3A5C3CCB4FBFBA5E3ECA9DC11F564B"
- $"584A544C504C0606AF0F2F3D2F3D393D4034BF593542324130432F42364432C0"
- $"3FBC5A2F48354A2F480608AE9A22303EB5BD3AB42542B755422E412F3C29322D"
- $"32223C0204263726372538263F253E263F304430443143303C313D303C02043D"
- $"423D423C433D4A3C493D4A495049504A4F49474A484947060DAEAAAE014E445A"
- $"3456365E325E3D5D3F5A3A5542544E4D573A4E364439463342324A2242310A0A"
- $"0002020102403CA00C88888C8CC1401673C40D6544F2950A01010002403CA000"
- $"0000000000401673C40D65446CF80A08020304023EC16A0000000000003EC16A"
- $"45DD1844C6550A030105123EC16A0000000000003EC16A45DD1844C655011784"
- $"22040A040105023EC16A0000000000003EC16A45DD1844C6550A030108123EC1"
- $"6A0000000000003EC16A45DD1844C65501178422040A0503080706023EC16A00"
- $"00000000003EC16A45DD1844C6550A030206071A3EC16A0000000000003EC16A"
- $"45DD1844C65510FF0215810004178222040A060106023EC16A0000000000003E"
- $"C16A45DD1844C6550A070107023EC16A0000000000003EC16A45DD1844C655"
-};
diff --git a/mesalib/src/mesa/main/api_exec.h b/mesalib/src/mesa/main/api_exec.h
index 12249fec2..655cb32d0 100644
--- a/mesalib/src/mesa/main/api_exec.h
+++ b/mesalib/src/mesa/main/api_exec.h
@@ -38,6 +38,9 @@ _mesa_initialize_exec_table(struct gl_context *ctx);
extern void
_mesa_initialize_dispatch_tables(struct gl_context *ctx);
+extern struct _glapi_table *
+_mesa_new_nop_table(unsigned numEntries);
+
#ifdef __cplusplus
} // extern "C"
#endif
diff --git a/mesalib/src/mesa/main/api_loopback.c b/mesalib/src/mesa/main/api_loopback.c
index 9932a8373..a7fd82c53 100644
--- a/mesalib/src/mesa/main/api_loopback.c
+++ b/mesalib/src/mesa/main/api_loopback.c
@@ -1772,7 +1772,9 @@ _mesa_loopback_init_api_table(const struct gl_context *ctx,
SET_VertexAttribI4sv(dest, _mesa_VertexAttribI4sv);
SET_VertexAttribI4ubv(dest, _mesa_VertexAttribI4ubv);
SET_VertexAttribI4usv(dest, _mesa_VertexAttribI4usv);
+ }
+ if (ctx->API == API_OPENGL_CORE) {
/* GL 4.1 / GL_ARB_vertex_attrib_64bit */
SET_VertexAttribL1d(dest, _mesa_VertexAttribL1d);
SET_VertexAttribL2d(dest, _mesa_VertexAttribL2d);
diff --git a/mesalib/src/mesa/main/arrayobj.c b/mesalib/src/mesa/main/arrayobj.c
index 320f435ea..7c4004043 100644
--- a/mesalib/src/mesa/main/arrayobj.c
+++ b/mesalib/src/mesa/main/arrayobj.c
@@ -617,14 +617,6 @@ void GLAPIENTRY
_mesa_CreateVertexArrays(GLsizei n, GLuint *arrays)
{
GET_CURRENT_CONTEXT(ctx);
-
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glCreateVertexArrays(GL_ARB_direct_state_access "
- "is not supported");
- return;
- }
-
gen_vertex_arrays(ctx, n, arrays, true, "glCreateVertexArrays");
}
@@ -667,13 +659,6 @@ _mesa_VertexArrayElementBuffer(GLuint vaobj, GLuint buffer)
struct gl_vertex_array_object *vao;
struct gl_buffer_object *bufObj;
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glVertexArrayElementBuffer(GL_ARB_direct_state_access "
- "is not supported");
- return;
- }
-
ASSERT_OUTSIDE_BEGIN_END(ctx);
/* The GL_ARB_direct_state_access specification says:
@@ -710,13 +695,6 @@ _mesa_GetVertexArrayiv(GLuint vaobj, GLenum pname, GLint *param)
ASSERT_OUTSIDE_BEGIN_END(ctx);
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glGetVertexArrayiv(GL_ARB_direct_state_access "
- "is not supported");
- return;
- }
-
/* The GL_ARB_direct_state_access specification says:
*
* "An INVALID_OPERATION error is generated if <vaobj> is not
diff --git a/mesalib/src/mesa/main/attrib.c b/mesalib/src/mesa/main/attrib.c
index b163c0aa6..53626e38b 100644
--- a/mesalib/src/mesa/main/attrib.c
+++ b/mesalib/src/mesa/main/attrib.c
@@ -177,6 +177,10 @@ struct texture_state
};
+/** An unused GL_*_BIT value */
+#define DUMMY_BIT 0x10000000
+
+
/**
* Allocate new attribute node of given type/kind. Attach payload data.
* Insert it into the linked list named by 'head'.
@@ -253,6 +257,15 @@ _mesa_PushAttrib(GLbitfield mask)
/* groups specified by the mask. */
head = NULL;
+ if (mask == 0) {
+ /* if mask is zero we still need to push something so that we
+ * don't get a GL_STACK_UNDERFLOW error in glPopAttrib().
+ */
+ GLuint dummy = 0;
+ if (!push_attrib(ctx, &head, DUMMY_BIT, sizeof(dummy), &dummy))
+ goto end;
+ }
+
if (mask & GL_ACCUM_BUFFER_BIT) {
if (!push_attrib(ctx, &head, GL_ACCUM_BUFFER_BIT,
sizeof(struct gl_accum_attrib),
@@ -928,6 +941,10 @@ _mesa_PopAttrib(void)
}
switch (attr->kind) {
+ case DUMMY_BIT:
+ /* do nothing */
+ break;
+
case GL_ACCUM_BUFFER_BIT:
{
const struct gl_accum_attrib *accum;
@@ -1074,6 +1091,11 @@ _mesa_PopAttrib(void)
_mesa_ClearDepth(depth->Clear);
_mesa_set_enable(ctx, GL_DEPTH_TEST, depth->Test);
_mesa_DepthMask(depth->Mask);
+ if (ctx->Extensions.EXT_depth_bounds_test) {
+ _mesa_set_enable(ctx, GL_DEPTH_BOUNDS_TEST_EXT,
+ depth->BoundsTest);
+ _mesa_DepthBoundsEXT(depth->BoundsMin, depth->BoundsMax);
+ }
}
break;
case GL_ENABLE_BIT:
diff --git a/mesalib/src/mesa/main/blit.c b/mesalib/src/mesa/main/blit.c
index fac972450..db8fee5a4 100644
--- a/mesalib/src/mesa/main/blit.c
+++ b/mesalib/src/mesa/main/blit.c
@@ -540,13 +540,6 @@ _mesa_BlitNamedFramebuffer(GLuint readFramebuffer, GLuint drawFramebuffer,
GET_CURRENT_CONTEXT(ctx);
struct gl_framebuffer *readFb, *drawFb;
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glBlitNamedFramebuffer(GL_ARB_direct_state_access "
- "is not supported)");
- return;
- }
-
if (MESA_VERBOSE & VERBOSE_API)
_mesa_debug(ctx,
"glBlitNamedFramebuffer(%u %u %d, %d, %d, %d, "
diff --git a/mesalib/src/mesa/main/bufferobj.c b/mesalib/src/mesa/main/bufferobj.c
index 660bc9489..66dee6802 100644
--- a/mesalib/src/mesa/main/bufferobj.c
+++ b/mesalib/src/mesa/main/bufferobj.c
@@ -1303,12 +1303,6 @@ create_buffers(GLsizei n, GLuint *buffers, bool dsa)
const char *func = dsa ? "glCreateBuffers" : "glGenBuffers";
- if (dsa && !ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "%s(GL_ARB_direct_state_access is not supported)", func);
- return;
- }
-
if (MESA_VERBOSE & VERBOSE_API)
_mesa_debug(ctx, "%s(%d)\n", func, n);
@@ -1483,13 +1477,6 @@ _mesa_NamedBufferStorage(GLuint buffer, GLsizeiptr size, const GLvoid *data,
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *bufObj;
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glNamedBufferStorage(GL_ARB_direct_state_access "
- "is not supported)");
- return;
- }
-
bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glNamedBufferStorage");
if (!bufObj)
return;
@@ -1616,13 +1603,6 @@ _mesa_NamedBufferData(GLuint buffer, GLsizeiptr size, const GLvoid *data,
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *bufObj;
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glNamedBufferData(GL_ARB_direct_state_access "
- "is not supported)");
- return;
- }
-
bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glNamedBufferData");
if (!bufObj)
return;
@@ -1693,13 +1673,6 @@ _mesa_NamedBufferSubData(GLuint buffer, GLintptr offset,
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *bufObj;
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glNamedBufferSubData(GL_ARB_direct_state_access "
- "is not supported)");
- return;
- }
-
bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glNamedBufferSubData");
if (!bufObj)
return;
@@ -1737,13 +1710,6 @@ _mesa_GetNamedBufferSubData(GLuint buffer, GLintptr offset,
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *bufObj;
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glGetNamedBufferSubData(GL_ARB_direct_state_access "
- "is not supported)");
- return;
- }
-
bufObj = _mesa_lookup_bufferobj_err(ctx, buffer,
"glGetNamedBufferSubData");
if (!bufObj)
@@ -1839,13 +1805,6 @@ _mesa_ClearNamedBufferData(GLuint buffer, GLenum internalformat,
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *bufObj;
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glClearNamedBufferData(GL_ARB_direct_state_access "
- "is not supported)");
- return;
- }
-
bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glClearNamedBufferData");
if (!bufObj)
return;
@@ -1883,13 +1842,6 @@ _mesa_ClearNamedBufferSubData(GLuint buffer, GLenum internalformat,
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *bufObj;
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glClearNamedBufferSubData(GL_ARB_direct_state_access "
- "is not supported)");
- return;
- }
-
bufObj = _mesa_lookup_bufferobj_err(ctx, buffer,
"glClearNamedBufferSubData");
if (!bufObj)
@@ -1978,13 +1930,6 @@ _mesa_UnmapNamedBuffer(GLuint buffer)
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *bufObj;
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glUnmapNamedBuffer(GL_ARB_direct_state_access "
- "is not supported)");
- return GL_FALSE;
- }
-
bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glUnmapNamedBuffer");
if (!bufObj)
return GL_FALSE;
@@ -2094,13 +2039,6 @@ _mesa_GetNamedBufferParameteriv(GLuint buffer, GLenum pname, GLint *params)
struct gl_buffer_object *bufObj;
GLint64 parameter;
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glGetNamedBufferParameteriv(GL_ARB_direct_state_access "
- "is not supported)");
- return;
- }
-
bufObj = _mesa_lookup_bufferobj_err(ctx, buffer,
"glGetNamedBufferParameteriv");
if (!bufObj)
@@ -2121,13 +2059,6 @@ _mesa_GetNamedBufferParameteri64v(GLuint buffer, GLenum pname,
struct gl_buffer_object *bufObj;
GLint64 parameter;
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glGetNamedBufferParameteri64v(GL_ARB_direct_state_access "
- "is not supported)");
- return;
- }
-
bufObj = _mesa_lookup_bufferobj_err(ctx, buffer,
"glGetNamedBufferParameteri64v");
if (!bufObj)
@@ -2167,13 +2098,6 @@ _mesa_GetNamedBufferPointerv(GLuint buffer, GLenum pname, GLvoid **params)
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *bufObj;
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glGetNamedBufferPointerv(GL_ARB_direct_state_access "
- "is not supported)");
- return;
- }
-
if (pname != GL_BUFFER_MAP_POINTER) {
_mesa_error(ctx, GL_INVALID_ENUM, "glGetNamedBufferPointerv(pname != "
"GL_BUFFER_MAP_POINTER)");
@@ -2288,13 +2212,6 @@ _mesa_CopyNamedBufferSubData(GLuint readBuffer, GLuint writeBuffer,
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *src, *dst;
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glCopyNamedBufferSubData(GL_ARB_direct_state_access "
- "is not supported)");
- return;
- }
-
src = _mesa_lookup_bufferobj_err(ctx, readBuffer,
"glCopyNamedBufferSubData");
if (!src)
@@ -2513,13 +2430,6 @@ _mesa_MapNamedBufferRange(GLuint buffer, GLintptr offset, GLsizeiptr length,
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *bufObj;
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glMapNamedBufferRange(GL_ARB_direct_state_access "
- "is not supported)");
- return NULL;
- }
-
if (!ctx->Extensions.ARB_map_buffer_range) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glMapNamedBufferRange("
@@ -2587,13 +2497,6 @@ _mesa_MapNamedBuffer(GLuint buffer, GLenum access)
struct gl_buffer_object *bufObj;
GLbitfield accessFlags;
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glMapNamedBuffer(GL_ARB_direct_state_access "
- "is not supported)");
- return NULL;
- }
-
if (!get_map_buffer_access_flags(ctx, access, &accessFlags)) {
_mesa_error(ctx, GL_INVALID_ENUM, "glMapNamedBuffer(invalid access)");
return NULL;
@@ -2684,14 +2587,6 @@ _mesa_FlushMappedNamedBufferRange(GLuint buffer, GLintptr offset,
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *bufObj;
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glFlushMappedNamedBufferRange(GL_ARB_direct_state_access "
- "is not supported)");
- return;
- }
-
-
bufObj = _mesa_lookup_bufferobj_err(ctx, buffer,
"glFlushMappedNamedBufferRange");
if (!bufObj)
diff --git a/mesalib/src/mesa/main/buffers.c b/mesalib/src/mesa/main/buffers.c
index c83459add..0536266d7 100644
--- a/mesalib/src/mesa/main/buffers.c
+++ b/mesalib/src/mesa/main/buffers.c
@@ -303,13 +303,6 @@ _mesa_NamedFramebufferDrawBuffer(GLuint framebuffer, GLenum buf)
GET_CURRENT_CONTEXT(ctx);
struct gl_framebuffer *fb;
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glNamedFramebufferDrawBuffer(GL_ARB_direct_state_access "
- "is not supported)");
- return;
- }
-
if (framebuffer) {
fb = _mesa_lookup_framebuffer_err(ctx, framebuffer,
"glNamedFramebufferDrawBuffer");
@@ -520,13 +513,6 @@ _mesa_NamedFramebufferDrawBuffers(GLuint framebuffer, GLsizei n,
GET_CURRENT_CONTEXT(ctx);
struct gl_framebuffer *fb;
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glNamedFramebufferDrawBuffers(GL_ARB_direct_state_access "
- "is not supported)");
- return;
- }
-
if (framebuffer) {
fb = _mesa_lookup_framebuffer_err(ctx, framebuffer,
"glNamedFramebufferDrawBuffers");
@@ -764,13 +750,6 @@ _mesa_NamedFramebufferReadBuffer(GLuint framebuffer, GLenum src)
GET_CURRENT_CONTEXT(ctx);
struct gl_framebuffer *fb;
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glNamedFramebufferReadBuffer(GL_ARB_direct_state_access "
- "is not supported)");
- return;
- }
-
if (framebuffer) {
fb = _mesa_lookup_framebuffer_err(ctx, framebuffer,
"glNamedFramebufferReadBuffer");
diff --git a/mesalib/src/mesa/main/clear.c b/mesalib/src/mesa/main/clear.c
index c6999f7fd..426caea47 100644
--- a/mesalib/src/mesa/main/clear.c
+++ b/mesalib/src/mesa/main/clear.c
@@ -412,14 +412,6 @@ _mesa_ClearNamedFramebufferiv(GLuint framebuffer, GLenum buffer,
{
GLint oldfb;
- GET_CURRENT_CONTEXT(ctx);
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glClearNamedFramebufferiv(GL_ARB_direct_state_access "
- "is not supported)");
- return;
- }
-
_mesa_GetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &oldfb);
_mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER, framebuffer);
_mesa_ClearBufferiv(buffer, drawbuffer, value);
@@ -510,14 +502,6 @@ _mesa_ClearNamedFramebufferuiv(GLuint framebuffer, GLenum buffer,
{
GLint oldfb;
- GET_CURRENT_CONTEXT(ctx);
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glClearNamedFramebufferuiv(GL_ARB_direct_state_access "
- "is not supported)");
- return;
- }
-
_mesa_GetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &oldfb);
_mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER, framebuffer);
_mesa_ClearBufferuiv(buffer, drawbuffer, value);
@@ -629,14 +613,6 @@ _mesa_ClearNamedFramebufferfv(GLuint framebuffer, GLenum buffer,
{
GLint oldfb;
- GET_CURRENT_CONTEXT(ctx);
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glClearNamedFramebufferfv(GL_ARB_direct_state_access "
- "is not supported)");
- return;
- }
-
_mesa_GetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &oldfb);
_mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER, framebuffer);
_mesa_ClearBufferfv(buffer, drawbuffer, value);
@@ -719,14 +695,6 @@ _mesa_ClearNamedFramebufferfi(GLuint framebuffer, GLenum buffer,
{
GLint oldfb;
- GET_CURRENT_CONTEXT(ctx);
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glClearNamedFramebufferfi(GL_ARB_direct_state_access "
- "is not supported)");
- return;
- }
-
_mesa_GetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &oldfb);
_mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER, framebuffer);
_mesa_ClearBufferfi(buffer, 0, depth, stencil);
diff --git a/mesalib/src/mesa/main/config.h b/mesalib/src/mesa/main/config.h
index 5a66a4eec..9c3baf4c6 100644
--- a/mesalib/src/mesa/main/config.h
+++ b/mesalib/src/mesa/main/config.h
@@ -213,19 +213,10 @@
/** For GL_ARB_fragment_program */
/*@{*/
#define MAX_FRAGMENT_PROGRAM_ADDRESS_REGS 0
+#define MAX_FRAGMENT_PROGRAM_PARAMS 64
+#define MAX_FRAGMENT_PROGRAM_INPUTS 12
/*@}*/
-/** For GL_NV_fragment_program */
-/*@{*/
-#define MAX_NV_FRAGMENT_PROGRAM_INSTRUCTIONS 1024 /* 72 for GL_ARB_f_p */
-#define MAX_NV_FRAGMENT_PROGRAM_TEMPS 96
-#define MAX_NV_FRAGMENT_PROGRAM_PARAMS 64
-#define MAX_NV_FRAGMENT_PROGRAM_INPUTS 12
-#define MAX_NV_FRAGMENT_PROGRAM_OUTPUTS 3
-#define MAX_NV_FRAGMENT_PROGRAM_WRITE_ONLYS 2
-/*@}*/
-
-
/** For GL_ARB_vertex_shader */
/*@{*/
#define MAX_VERTEX_GENERIC_ATTRIBS 16
diff --git a/mesalib/src/mesa/main/context.c b/mesalib/src/mesa/main/context.c
index 544cc142f..79fa01849 100644
--- a/mesalib/src/mesa/main/context.c
+++ b/mesalib/src/mesa/main/context.c
@@ -489,8 +489,8 @@ init_program_limits(struct gl_constants *consts, gl_shader_stage stage,
prog->MaxOutputComponents = 16 * 4; /* old limit not to break tnl and swrast */
break;
case MESA_SHADER_FRAGMENT:
- prog->MaxParameters = MAX_NV_FRAGMENT_PROGRAM_PARAMS;
- prog->MaxAttribs = MAX_NV_FRAGMENT_PROGRAM_INPUTS;
+ prog->MaxParameters = MAX_FRAGMENT_PROGRAM_PARAMS;
+ prog->MaxAttribs = MAX_FRAGMENT_PROGRAM_INPUTS;
prog->MaxAddressRegs = MAX_FRAGMENT_PROGRAM_ADDRESS_REGS;
prog->MaxUniformComponents = 4 * MAX_UNIFORMS;
prog->MaxInputComponents = 16 * 4; /* old limit not to break tnl and swrast */
@@ -883,6 +883,19 @@ update_default_objects(struct gl_context *ctx)
}
+/* XXX this is temporary and should be removed at some point in the
+ * future when there's a reasonable expectation that the libGL library
+ * contains the _glapi_new_nop_table() and _glapi_set_nop_handler()
+ * functions which were added in Mesa 10.6.
+ */
+#if !defined(_WIN32)
+/* Avoid libGL / driver ABI break */
+#define USE_GLAPI_NOP_FEATURES 0
+#else
+#define USE_GLAPI_NOP_FEATURES 1
+#endif
+
+
/**
* This function is called by the glapi no-op functions. For each OpenGL
* function/entrypoint there's a simple no-op function. These "no-op"
@@ -898,6 +911,7 @@ update_default_objects(struct gl_context *ctx)
*
* \param name the name of the OpenGL function
*/
+#if USE_GLAPI_NOP_FEATURES
static void
nop_handler(const char *name)
{
@@ -914,6 +928,7 @@ nop_handler(const char *name)
}
#endif
}
+#endif
/**
@@ -923,12 +938,52 @@ nop_handler(const char *name)
static void GLAPIENTRY
nop_glFlush(void)
{
- /* don't record an error like we do in _mesa_generic_nop() */
+ /* don't record an error like we do in nop_handler() */
+}
+#endif
+
+
+#if !USE_GLAPI_NOP_FEATURES
+static int
+generic_nop(void)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "unsupported function called "
+ "(unsupported extension or deprecated function?)");
+ return 0;
}
#endif
/**
+ * Create a new API dispatch table in which all entries point to the
+ * generic_nop() function. This will not work on Windows because of
+ * the __stdcall convention which requires the callee to clean up the
+ * call stack. That's impossible with one generic no-op function.
+ */
+struct _glapi_table *
+_mesa_new_nop_table(unsigned numEntries)
+{
+ struct _glapi_table *table;
+
+#if !USE_GLAPI_NOP_FEATURES
+ table = malloc(numEntries * sizeof(_glapi_proc));
+ if (table) {
+ _glapi_proc *entry = (_glapi_proc *) table;
+ unsigned i;
+ for (i = 0; i < numEntries; i++) {
+ entry[i] = (_glapi_proc) generic_nop;
+ }
+ }
+#else
+ table = _glapi_new_nop_table(numEntries);
+#endif
+ return table;
+}
+
+
+/**
* Allocate and initialize a new dispatch table. The table will be
* populated with pointers to "no-op" functions. In turn, the no-op
* functions will call nop_handler() above.
@@ -941,8 +996,9 @@ alloc_dispatch_table(void)
* Mesa we do this to accommodate different versions of libGL and various
* DRI drivers.
*/
- GLint numEntries = MAX2(_glapi_get_dispatch_table_size(), _gloffset_COUNT);
- struct _glapi_table *table = _glapi_new_nop_table(numEntries);
+ int numEntries = MAX2(_glapi_get_dispatch_table_size(), _gloffset_COUNT);
+
+ struct _glapi_table *table = _mesa_new_nop_table(numEntries);
#if defined(_WIN32)
if (table) {
@@ -966,7 +1022,9 @@ alloc_dispatch_table(void)
}
#endif
+#if USE_GLAPI_NOP_FEATURES
_glapi_set_nop_handler(nop_handler);
+#endif
return table;
}
@@ -1111,9 +1169,7 @@ _mesa_initialize_context(struct gl_context *ctx,
ctx->HasConfig = GL_FALSE;
}
- if (_mesa_is_desktop_gl(ctx)) {
- _mesa_override_gl_version(ctx);
- }
+ _mesa_override_gl_version(ctx);
/* misc one-time initializations */
one_time_init(ctx);
@@ -1275,7 +1331,6 @@ _mesa_free_context_data( struct gl_context *ctx )
_mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current, NULL);
_mesa_reference_vertprog(ctx, &ctx->VertexProgram._TnlProgram, NULL);
- _mesa_reference_geomprog(ctx, &ctx->GeometryProgram.Current, NULL);
_mesa_reference_geomprog(ctx, &ctx->GeometryProgram._Current, NULL);
_mesa_reference_fragprog(ctx, &ctx->FragmentProgram.Current, NULL);
diff --git a/mesalib/src/mesa/main/copyimage.c b/mesalib/src/mesa/main/copyimage.c
index fd22f2889..e8732c617 100644
--- a/mesalib/src/mesa/main/copyimage.c
+++ b/mesalib/src/mesa/main/copyimage.c
@@ -40,14 +40,25 @@ enum mesa_block_class {
BLOCK_CLASS_64_BITS
};
+/**
+ * Prepare the source or destination resource, including:
+ * - Error checking
+ * - Creating texture wrappers for renderbuffers
+ * \param name the texture or renderbuffer name
+ * \param target GL_TEXTURE target or GL_RENDERBUFFER. For the later, will
+ * be changed to a compatible GL_TEXTURE target.
+ * \param level mipmap level
+ * \param tex_obj returns a pointer to a texture object
+ * \param tex_image returns a pointer to a texture image
+ * \param tmp_tex returns temporary texture object name
+ * \return true if success, false if error
+ */
static bool
prepare_target(struct gl_context *ctx, GLuint name, GLenum *target, int level,
struct gl_texture_object **tex_obj,
struct gl_texture_image **tex_image, GLuint *tmp_tex,
const char *dbg_prefix)
{
- struct gl_renderbuffer *rb;
-
if (name == 0) {
_mesa_error(ctx, GL_INVALID_VALUE,
"glCopyImageSubData(%sName = %d)", dbg_prefix, name);
@@ -87,7 +98,7 @@ prepare_target(struct gl_context *ctx, GLuint name, GLenum *target, int level,
}
if (*target == GL_RENDERBUFFER) {
- rb = _mesa_lookup_renderbuffer(ctx, name);
+ struct gl_renderbuffer *rb = _mesa_lookup_renderbuffer(ctx, name);
if (!rb) {
_mesa_error(ctx, GL_INVALID_VALUE,
"glCopyImageSubData(%sName = %u)", dbg_prefix, name);
@@ -169,8 +180,15 @@ prepare_target(struct gl_context *ctx, GLuint name, GLenum *target, int level,
return true;
}
+
+/**
+ * Check that the x,y,z,width,height,region is within the texture image
+ * dimensions.
+ * \return true if bounds OK, false if regions is out of bounds
+ */
static bool
-check_region_bounds(struct gl_context *ctx, struct gl_texture_image *tex_image,
+check_region_bounds(struct gl_context *ctx,
+ const struct gl_texture_image *tex_image,
int x, int y, int z, int width, int height, int depth,
const char *dbg_prefix)
{
@@ -188,6 +206,7 @@ check_region_bounds(struct gl_context *ctx, struct gl_texture_image *tex_image,
return false;
}
+ /* Check X direction */
if (x + width > tex_image->Width) {
_mesa_error(ctx, GL_INVALID_VALUE,
"glCopyImageSubData(%sX or %sWidth exceeds image bounds)",
@@ -195,6 +214,7 @@ check_region_bounds(struct gl_context *ctx, struct gl_texture_image *tex_image,
return false;
}
+ /* Check Y direction */
switch (tex_image->TexObject->Target) {
case GL_TEXTURE_1D:
case GL_TEXTURE_1D_ARRAY:
@@ -215,6 +235,7 @@ check_region_bounds(struct gl_context *ctx, struct gl_texture_image *tex_image,
break;
}
+ /* Check Z direction */
switch (tex_image->TexObject->Target) {
case GL_TEXTURE_1D:
case GL_TEXTURE_2D:
@@ -260,7 +281,7 @@ check_region_bounds(struct gl_context *ctx, struct gl_texture_image *tex_image,
}
static bool
-compressed_format_compatible(struct gl_context *ctx,
+compressed_format_compatible(const struct gl_context *ctx,
GLenum compressedFormat, GLenum otherFormat)
{
enum mesa_block_class compressedClass, otherClass;
@@ -348,8 +369,8 @@ compressed_format_compatible(struct gl_context *ctx,
}
static bool
-copy_format_compatible(struct gl_context *ctx,
- GLenum srcFormat, GLenum dstFormat)
+copy_format_compatible(const struct gl_context *ctx,
+ GLenum srcFormat, GLenum dstFormat)
{
/*
* From ARB_copy_image spec:
@@ -389,7 +410,7 @@ _mesa_CopyImageSubData(GLuint srcName, GLenum srcTarget, GLint srcLevel,
struct gl_texture_object *srcTexObj, *dstTexObj;
struct gl_texture_image *srcTexImage, *dstTexImage;
GLuint src_bw, src_bh, dst_bw, dst_bh;
- int i, srcNewZ, dstNewZ;
+ int i;
if (MESA_VERBOSE & VERBOSE_API)
_mesa_debug(ctx, "glCopyImageSubData(%u, %s, %d, %d, %d, %d, "
@@ -447,6 +468,8 @@ _mesa_CopyImageSubData(GLuint srcName, GLenum srcTarget, GLint srcLevel,
}
for (i = 0; i < srcDepth; ++i) {
+ int srcNewZ, dstNewZ;
+
if (srcTexObj->Target == GL_TEXTURE_CUBE_MAP) {
srcTexImage = srcTexObj->Image[i + srcZ][srcLevel];
srcNewZ = 0;
diff --git a/mesalib/src/mesa/main/depth.c b/mesalib/src/mesa/main/depth.c
index 29851ecb8..bb4591cf1 100644
--- a/mesalib/src/mesa/main/depth.c
+++ b/mesalib/src/mesa/main/depth.c
@@ -65,6 +65,9 @@ _mesa_DepthFunc( GLenum func )
if (MESA_VERBOSE & VERBOSE_API)
_mesa_debug(ctx, "glDepthFunc %s\n", _mesa_lookup_enum_by_nr(func));
+ if (ctx->Depth.Func == func)
+ return;
+
switch (func) {
case GL_LESS: /* (default) pass if incoming z < stored z */
case GL_GEQUAL:
@@ -80,9 +83,6 @@ _mesa_DepthFunc( GLenum func )
return;
}
- if (ctx->Depth.Func == func)
- return;
-
FLUSH_VERTICES(ctx, _NEW_DEPTH);
ctx->Depth.Func = func;
diff --git a/mesalib/src/mesa/main/dlist.c b/mesalib/src/mesa/main/dlist.c
index 431c4b48b..aafe486fb 100644
--- a/mesalib/src/mesa/main/dlist.c
+++ b/mesalib/src/mesa/main/dlist.c
@@ -7592,28 +7592,6 @@ save_FramebufferTexture(GLenum target, GLenum attachment,
}
}
-static void GLAPIENTRY
-save_FramebufferTextureFace(GLenum target, GLenum attachment,
- GLuint texture, GLint level, GLenum face)
-{
- Node *n;
- GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
- n = alloc_instruction(ctx, OPCODE_FRAMEBUFFER_TEXTURE_FACE, 5);
- if (n) {
- n[1].e = target;
- n[2].e = attachment;
- n[3].ui = texture;
- n[4].i = level;
- n[5].e = face;
- }
- if (ctx->ExecuteFlag) {
- CALL_FramebufferTextureFaceARB(ctx->Exec, (target, attachment, texture,
- level, face));
- }
-}
-
-
static void GLAPIENTRY
save_WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
@@ -8873,11 +8851,6 @@ execute_list(struct gl_context *ctx, GLuint list)
CALL_FramebufferTexture(ctx->Exec, (n[1].e, n[2].e,
n[3].ui, n[4].i));
break;
- case OPCODE_FRAMEBUFFER_TEXTURE_FACE:
- CALL_FramebufferTextureFaceARB(ctx->Exec, (n[1].e, n[2].e,
- n[3].ui, n[4].i, n[5].e));
- break;
-
/* GL_ARB_sync */
case OPCODE_WAIT_SYNC:
{
@@ -9644,10 +9617,9 @@ _mesa_initialize_save_table(const struct gl_context *ctx)
SET_BlendEquationiARB(table, save_BlendEquationi);
SET_BlendEquationSeparateiARB(table, save_BlendEquationSeparatei);
- /* GL_ARB_geometry_shader4 */
+ /* OpenGL 3.2 */
SET_ProgramParameteri(table, save_ProgramParameteri);
SET_FramebufferTexture(table, save_FramebufferTexture);
- SET_FramebufferTextureFaceARB(table, save_FramebufferTextureFace);
/* GL_NV_conditional_render */
SET_BeginConditionalRender(table, save_BeginConditionalRender);
diff --git a/mesalib/src/mesa/main/errors.c b/mesalib/src/mesa/main/errors.c
index 2aa1deb63..16f10ddb6 100644
--- a/mesalib/src/mesa/main/errors.c
+++ b/mesalib/src/mesa/main/errors.c
@@ -39,6 +39,7 @@
#include "mtypes.h"
#include "version.h"
#include "util/hash_table.h"
+#include "util/simple_list.h"
static mtx_t DynamicIDMutex = _MTX_INITIALIZER_NP;
static GLuint NextDynamicID = 1;
diff --git a/mesalib/src/mesa/main/extensions.c b/mesalib/src/mesa/main/extensions.c
index c82416aa0..f9bf503a0 100644
--- a/mesalib/src/mesa/main/extensions.c
+++ b/mesalib/src/mesa/main/extensions.c
@@ -104,7 +104,7 @@ static const struct extension extension_table[] = {
{ "GL_ARB_depth_clamp", o(ARB_depth_clamp), GL, 2003 },
{ "GL_ARB_depth_texture", o(ARB_depth_texture), GLL, 2001 },
{ "GL_ARB_derivative_control", o(ARB_derivative_control), GL, 2014 },
- { "GL_ARB_direct_state_access", o(ARB_direct_state_access), GL, 2014 },
+ { "GL_ARB_direct_state_access", o(dummy_true), GLC, 2014 },
{ "GL_ARB_draw_buffers", o(dummy_true), GL, 2002 },
{ "GL_ARB_draw_buffers_blend", o(ARB_draw_buffers_blend), GL, 2009 },
{ "GL_ARB_draw_elements_base_vertex", o(ARB_draw_elements_base_vertex), GL, 2009 },
diff --git a/mesalib/src/mesa/main/fbobject.c b/mesalib/src/mesa/main/fbobject.c
index 8db651ca2..c5a702636 100644
--- a/mesalib/src/mesa/main/fbobject.c
+++ b/mesalib/src/mesa/main/fbobject.c
@@ -1489,14 +1489,6 @@ void GLAPIENTRY
_mesa_CreateRenderbuffers(GLsizei n, GLuint *renderbuffers)
{
GET_CURRENT_CONTEXT(ctx);
-
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glCreateRenderbuffers(GL_ARB_direct_state_access "
- "is not supported)");
- return;
- }
-
create_render_buffers(ctx, n, renderbuffers, true);
}
@@ -1937,12 +1929,6 @@ renderbuffer_storage_named(GLuint renderbuffer, GLenum internalFormat,
{
GET_CURRENT_CONTEXT(ctx);
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "%s(GL_ARB_direct_state_access is not supported)", func);
- return;
- }
-
if (MESA_VERBOSE & VERBOSE_API) {
if (samples == NO_SAMPLES)
_mesa_debug(ctx, "%s(%u, %s, %d, %d)\n",
@@ -2197,13 +2183,6 @@ _mesa_GetNamedRenderbufferParameteriv(GLuint renderbuffer, GLenum pname,
{
GET_CURRENT_CONTEXT(ctx);
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glGetNamedRenderbufferParameteriv("
- "GL_ARB_direct_state_access is not supported)");
- return;
- }
-
struct gl_renderbuffer *rb = _mesa_lookup_renderbuffer(ctx, renderbuffer);
if (!rb || rb == &DummyRenderbuffer) {
/* ID was reserved, but no real renderbuffer object made yet */
@@ -2475,12 +2454,6 @@ create_framebuffers(GLsizei n, GLuint *framebuffers, bool dsa)
const char *func = dsa ? "glCreateFramebuffers" : "glGenFramebuffers";
- if (dsa && !ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "%s(GL_ARB_direct_state_access is not supported)", func);
- return;
- }
-
if (n < 0) {
_mesa_error(ctx, GL_INVALID_VALUE, "%s(n < 0)", func);
return;
@@ -2579,13 +2552,6 @@ _mesa_CheckNamedFramebufferStatus(GLuint framebuffer, GLenum target)
struct gl_framebuffer *fb;
GET_CURRENT_CONTEXT(ctx);
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glCheckNamedFramebufferStatus(GL_ARB_direct_state_access "
- "is not supported)");
- return 0;
- }
-
/* Validate the target (for conformance's sake) and grab a reference to the
* default framebuffer in case framebuffer = 0.
* Section 9.4 Framebuffer Completeness of the OpenGL 4.5 core spec
@@ -2741,6 +2707,10 @@ check_texture_target(struct gl_context *ctx, GLenum target,
/* We're being called by glFramebufferTextureLayer().
* The only legal texture types for that function are 3D,
* cube-map, and 1D/2D/cube-map array textures.
+ *
+ * We don't need to check for GL_ARB_texture_cube_map_array because the
+ * application wouldn't have been able to create a texture with a
+ * GL_TEXTURE_CUBE_MAP_ARRAY target if the extension were not enabled.
*/
switch (target) {
case GL_TEXTURE_3D:
@@ -2750,10 +2720,13 @@ check_texture_target(struct gl_context *ctx, GLenum target,
case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
return true;
case GL_TEXTURE_CUBE_MAP:
- /* This target is valid in TextureLayer when ARB_direct_state_access
- * or OpenGL 4.5 is supported.
+ /* We don't need to check the extension (GL_ARB_direct_state_access) or
+ * GL version (4.5) for GL_TEXTURE_CUBE_MAP because DSA is always
+ * enabled in core profile. This can be called from
+ * _mesa_FramebufferTextureLayer in compatibility profile (OpenGL 3.0),
+ * so we do have to check the profile.
*/
- return ctx->Extensions.ARB_direct_state_access;
+ return ctx->API == API_OPENGL_CORE;
}
_mesa_error(ctx, GL_INVALID_OPERATION,
@@ -3131,12 +3104,6 @@ _mesa_NamedFramebufferTextureLayer(GLuint framebuffer, GLenum attachment,
const char *func = "glNamedFramebufferTextureLayer";
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "%s(GL_ARB_direct_state_access is not supported)", func);
- return;
- }
-
/* Get the framebuffer object */
fb = _mesa_lookup_framebuffer_err(ctx, framebuffer, func);
if (!fb)
@@ -3222,12 +3189,6 @@ _mesa_NamedFramebufferTexture(GLuint framebuffer, GLenum attachment,
const char *func = "glNamedFramebufferTexture";
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "%s(GL_ARB_direct_state_access is not supported)", func);
- return;
- }
-
if (!_mesa_has_geometry_shaders(ctx)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"unsupported function (glNamedFramebufferTexture) called");
@@ -3353,15 +3314,10 @@ _mesa_NamedFramebufferRenderbuffer(GLuint framebuffer, GLenum attachment,
struct gl_renderbuffer *rb;
GET_CURRENT_CONTEXT(ctx);
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glNamedFramebufferRenderbuffer(GL_ARB_direct_state_access "
- "is not supported)");
- return;
- }
-
fb = _mesa_lookup_framebuffer_err(ctx, framebuffer,
"glNamedFramebufferRenderbuffer");
+ if (!fb)
+ return;
if (renderbuffertarget != GL_RENDERBUFFER) {
_mesa_error(ctx, GL_INVALID_ENUM,
@@ -3692,13 +3648,6 @@ _mesa_GetNamedFramebufferAttachmentParameteriv(GLuint framebuffer,
GET_CURRENT_CONTEXT(ctx);
struct gl_framebuffer *buffer;
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glGetNamedFramebufferAttachmentParameteriv("
- "GL_ARB_direct_state_access is not supported)");
- return;
- }
-
if (framebuffer) {
buffer = _mesa_lookup_framebuffer_err(ctx, framebuffer,
"glGetNamedFramebufferAttachmentParameteriv");
@@ -3731,13 +3680,6 @@ _mesa_NamedFramebufferParameteri(GLuint framebuffer, GLenum pname,
(void) pname;
(void) param;
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glNamedFramebufferParameteri("
- "GL_ARB_direct_state_access is not supported)");
- return;
- }
-
_mesa_error(ctx, GL_INVALID_OPERATION,
"glNamedFramebufferParameteri not supported "
"(ARB_framebuffer_no_attachments not implemented)");
@@ -3754,13 +3696,6 @@ _mesa_GetNamedFramebufferParameteriv(GLuint framebuffer, GLenum pname,
(void) pname;
(void) param;
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glNamedFramebufferParameteriv("
- "GL_ARB_direct_state_access is not supported)");
- return;
- }
-
_mesa_error(ctx, GL_INVALID_OPERATION,
"glGetNamedFramebufferParameteriv not supported "
"(ARB_framebuffer_no_attachments not implemented)");
@@ -3929,13 +3864,6 @@ _mesa_InvalidateNamedFramebufferSubData(GLuint framebuffer,
struct gl_framebuffer *fb;
GET_CURRENT_CONTEXT(ctx);
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glInvalidateNamedFramebufferSubData("
- "GL_ARB_direct_state_access is not supported)");
- return;
- }
-
/* The OpenGL 4.5 core spec (02.02.2015) says (in Section 17.4 Whole
* Framebuffer Operations, PDF page 522): "If framebuffer is zero, the
* default draw framebuffer is affected."
@@ -3997,13 +3925,6 @@ _mesa_InvalidateNamedFramebufferData(GLuint framebuffer,
struct gl_framebuffer *fb;
GET_CURRENT_CONTEXT(ctx);
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glInvalidateNamedFramebufferData("
- "GL_ARB_direct_state_access is not supported)");
- return;
- }
-
/* The OpenGL 4.5 core spec (02.02.2015) says (in Section 17.4 Whole
* Framebuffer Operations, PDF page 522): "If framebuffer is zero, the
* default draw framebuffer is affected."
diff --git a/mesalib/src/mesa/main/formats.c b/mesalib/src/mesa/main/formats.c
index 8af44e905..baeb1bfe5 100644
--- a/mesalib/src/mesa/main/formats.c
+++ b/mesalib/src/mesa/main/formats.c
@@ -397,6 +397,11 @@ format_array_format_table_init(void)
format_array_format_table = _mesa_hash_table_create(NULL, NULL,
array_formats_equal);
+ if (!format_array_format_table) {
+ _mesa_error_no_memory(__func__);
+ return;
+ }
+
for (f = 1; f < MESA_FORMAT_COUNT; ++f) {
info = _mesa_get_format_info(f);
if (!info->ArrayFormat)
@@ -432,6 +437,12 @@ _mesa_format_from_array_format(uint32_t array_format)
call_once(&format_array_format_table_exists, format_array_format_table_init);
+ if (!format_array_format_table) {
+ static const once_flag once_flag_init = ONCE_FLAG_INIT;
+ format_array_format_table_exists = once_flag_init;
+ return MESA_FORMAT_NONE;
+ }
+
entry = _mesa_hash_table_search_pre_hashed(format_array_format_table,
array_format,
(void *)(intptr_t)array_format);
diff --git a/mesalib/src/mesa/main/genmipmap.c b/mesalib/src/mesa/main/genmipmap.c
index 32b9460ad..9aef09019 100644
--- a/mesalib/src/mesa/main/genmipmap.c
+++ b/mesalib/src/mesa/main/genmipmap.c
@@ -158,13 +158,6 @@ _mesa_GenerateTextureMipmap(GLuint texture)
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glGenerateTextureMipmap(GL_ARB_direct_state_access "
- "is not supported)");
- return;
- }
-
texObj = _mesa_lookup_texture_err(ctx, texture, "glGenerateTextureMipmap");
if (!texObj)
return;
diff --git a/mesalib/src/mesa/main/get.c b/mesalib/src/mesa/main/get.c
index 8a6c81aff..1bc9b5d82 100644
--- a/mesalib/src/mesa/main/get.c
+++ b/mesalib/src/mesa/main/get.c
@@ -138,6 +138,7 @@ enum value_extra {
EXTRA_API_GL_CORE,
EXTRA_API_ES2,
EXTRA_API_ES3,
+ EXTRA_API_ES31,
EXTRA_NEW_BUFFERS,
EXTRA_NEW_FRAG_CLAMP,
EXTRA_VALID_DRAW_BUFFER,
@@ -348,6 +349,12 @@ static const int extra_ARB_shader_image_load_store_and_geometry_shader[] = {
EXTRA_END
};
+static const int extra_ARB_draw_indirect_es31[] = {
+ EXT(ARB_draw_indirect),
+ EXTRA_API_ES31,
+ EXTRA_END
+};
+
EXTRA_EXT(ARB_texture_cube_map);
EXTRA_EXT(EXT_texture_array);
EXTRA_EXT(NV_fog_distance);
@@ -1078,6 +1085,11 @@ check_extra(struct gl_context *ctx, const char *func, const struct value_desc *d
if (_mesa_is_gles3(ctx))
api_found = GL_TRUE;
break;
+ case EXTRA_API_ES31:
+ api_check = GL_TRUE;
+ if (_mesa_is_gles31(ctx))
+ api_found = GL_TRUE;
+ break;
case EXTRA_API_GL:
api_check = GL_TRUE;
if (_mesa_is_desktop_gl(ctx))
diff --git a/mesalib/src/mesa/main/get_hash_params.py b/mesalib/src/mesa/main/get_hash_params.py
index 41cb2c17b..513d5d21b 100644
--- a/mesalib/src/mesa/main/get_hash_params.py
+++ b/mesalib/src/mesa/main/get_hash_params.py
@@ -409,6 +409,12 @@ descriptor=[
[ "SAMPLER_BINDING", "LOC_CUSTOM, TYPE_INT, GL_SAMPLER_BINDING, NO_EXTRA" ],
]},
+# Enums in OpenGL Core profile and ES 3.1
+{ "apis": ["GL_CORE", "GLES3"], "params": [
+# GL_ARB_draw_indirect / GLES 3.1
+ [ "DRAW_INDIRECT_BUFFER_BINDING", "LOC_CUSTOM, TYPE_INT, 0, extra_ARB_draw_indirect_es31" ],
+]},
+
# Remaining enums are only in OpenGL
{ "apis": ["GL", "GL_CORE"], "params": [
[ "ACCUM_RED_BITS", "BUFFER_INT(Visual.accumRedBits), NO_EXTRA" ],
@@ -804,8 +810,6 @@ descriptor=[
{ "apis": ["GL_CORE"], "params": [
# GL_ARB_texture_buffer_range
[ "TEXTURE_BUFFER_OFFSET_ALIGNMENT", "CONTEXT_INT(Const.TextureBufferOffsetAlignment), extra_ARB_texture_buffer_range" ],
-# GL_ARB_draw_indirect
- [ "DRAW_INDIRECT_BUFFER_BINDING", "LOC_CUSTOM, TYPE_INT, 0, extra_ARB_draw_indirect" ],
# GL_ARB_viewport_array
[ "MAX_VIEWPORTS", "CONTEXT_INT(Const.MaxViewports), extra_ARB_viewport_array" ],
diff --git a/mesalib/src/mesa/main/getstring.c b/mesalib/src/mesa/main/getstring.c
index 1b2c7f054..72d99ca4e 100644
--- a/mesalib/src/mesa/main/getstring.c
+++ b/mesalib/src/mesa/main/getstring.c
@@ -72,10 +72,18 @@ shading_language_version(struct gl_context *ctx)
break;
case API_OPENGLES2:
- return (ctx->Version < 30)
- ? (const GLubyte *) "OpenGL ES GLSL ES 1.0.16"
- : (const GLubyte *) "OpenGL ES GLSL ES 3.00";
-
+ switch (ctx->Version) {
+ case 20:
+ return (const GLubyte *) "OpenGL ES GLSL ES 1.0.16";
+ case 30:
+ return (const GLubyte *) "OpenGL ES GLSL ES 3.00";
+ case 31:
+ return (const GLubyte *) "OpenGL ES GLSL ES 3.10";
+ default:
+ _mesa_problem(ctx,
+ "Invalid OpenGL ES version in shading_language_version()");
+ return (const GLubyte *) 0;
+ }
case API_OPENGLES:
/* fall-through */
diff --git a/mesalib/src/mesa/main/glformats.c b/mesalib/src/mesa/main/glformats.c
index 8ced57949..ac69fabcc 100644
--- a/mesalib/src/mesa/main/glformats.c
+++ b/mesalib/src/mesa/main/glformats.c
@@ -1200,7 +1200,7 @@ _mesa_is_depth_or_stencil_format(GLenum format)
* \return GL_TRUE if compressed, GL_FALSE if uncompressed
*/
GLboolean
-_mesa_is_compressed_format(struct gl_context *ctx, GLenum format)
+_mesa_is_compressed_format(const struct gl_context *ctx, GLenum format)
{
switch (format) {
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
@@ -1678,6 +1678,10 @@ _mesa_error_check_format_and_type(const struct gl_context *ctx,
case GL_LUMINANCE:
case GL_ALPHA:
return GL_NO_ERROR;
+ case GL_RG:
+ case GL_RED:
+ if (_mesa_is_gles3(ctx) || ctx->Extensions.ARB_texture_rg)
+ return GL_NO_ERROR;
default:
return GL_INVALID_OPERATION;
}
@@ -2292,8 +2296,18 @@ _mesa_es3_error_check_format_and_type(const struct gl_context *ctx,
break;
case GL_HALF_FLOAT:
- if (internalFormat != GL_RG16F)
- return GL_INVALID_OPERATION;
+ case GL_HALF_FLOAT_OES:
+ switch (internalFormat) {
+ case GL_RG16F:
+ break;
+ case GL_RG:
+ if (ctx->Extensions.ARB_texture_rg &&
+ ctx->Extensions.OES_texture_half_float)
+ break;
+ /* fallthrough */
+ default:
+ return GL_INVALID_OPERATION;
+ }
break;
case GL_FLOAT:
@@ -2301,6 +2315,11 @@ _mesa_es3_error_check_format_and_type(const struct gl_context *ctx,
case GL_RG16F:
case GL_RG32F:
break;
+ case GL_RG:
+ if (ctx->Extensions.ARB_texture_rg &&
+ ctx->Extensions.OES_texture_float)
+ break;
+ /* fallthrough */
default:
return GL_INVALID_OPERATION;
}
@@ -2361,8 +2380,19 @@ _mesa_es3_error_check_format_and_type(const struct gl_context *ctx,
break;
case GL_HALF_FLOAT:
- if (internalFormat != GL_R16F)
+ case GL_HALF_FLOAT_OES:
+ switch (internalFormat) {
+ case GL_R16F:
+ break;
+ case GL_RG:
+ case GL_RED:
+ if (ctx->Extensions.ARB_texture_rg &&
+ ctx->Extensions.OES_texture_half_float)
+ break;
+ /* fallthrough */
+ default:
return GL_INVALID_OPERATION;
+ }
break;
case GL_FLOAT:
@@ -2370,6 +2400,11 @@ _mesa_es3_error_check_format_and_type(const struct gl_context *ctx,
case GL_R16F:
case GL_R32F:
break;
+ case GL_RED:
+ if (ctx->Extensions.ARB_texture_rg &&
+ ctx->Extensions.OES_texture_float)
+ break;
+ /* fallthrough */
default:
return GL_INVALID_OPERATION;
}
diff --git a/mesalib/src/mesa/main/glformats.h b/mesalib/src/mesa/main/glformats.h
index e1ecd64d5..8881cb7d8 100644
--- a/mesalib/src/mesa/main/glformats.h
+++ b/mesalib/src/mesa/main/glformats.h
@@ -96,7 +96,7 @@ extern GLboolean
_mesa_is_depth_or_stencil_format(GLenum format);
extern GLboolean
-_mesa_is_compressed_format(struct gl_context *ctx, GLenum format);
+_mesa_is_compressed_format(const struct gl_context *ctx, GLenum format);
extern GLenum
_mesa_base_format_to_integer_format(GLenum format);
diff --git a/mesalib/src/mesa/main/glheader.h b/mesalib/src/mesa/main/glheader.h
index 7f7f9a39b..a2d98d4dd 100644
--- a/mesalib/src/mesa/main/glheader.h
+++ b/mesalib/src/mesa/main/glheader.h
@@ -135,12 +135,6 @@ typedef void *GLeglImageOES;
#define GL_SHADER_PROGRAM_MESA 0x9999
-/**
- * Internal token for geometry programs.
- * Use the value for GL_GEOMETRY_PROGRAM_NV for now.
- */
-#define MESA_GEOMETRY_PROGRAM 0x8c26
-
/* Several fields of struct gl_config can take these as values. Since
* GLX header files may not be available everywhere they need to be used,
* redefine them here.
diff --git a/mesalib/src/mesa/main/hash.c b/mesalib/src/mesa/main/hash.c
index d04cccd94..315b5d640 100644
--- a/mesalib/src/mesa/main/hash.c
+++ b/mesalib/src/mesa/main/hash.c
@@ -389,34 +389,6 @@ _mesa_HashDeleteAll(struct _mesa_HashTable *table,
/**
- * Clone all entries in a hash table, into a new table.
- *
- * \param table the hash table to clone
- */
-struct _mesa_HashTable *
-_mesa_HashClone(const struct _mesa_HashTable *table)
-{
- /* cast-away const */
- struct _mesa_HashTable *table2 = (struct _mesa_HashTable *) table;
- struct hash_entry *entry;
- struct _mesa_HashTable *clonetable;
-
- assert(table);
- mtx_lock(&table2->Mutex);
-
- clonetable = _mesa_NewHashTable();
- assert(clonetable);
- hash_table_foreach(table->ht, entry) {
- _mesa_HashInsert(clonetable, (GLint)(uintptr_t)entry->key, entry->data);
- }
-
- mtx_unlock(&table2->Mutex);
-
- return clonetable;
-}
-
-
-/**
* Walk over all entries in a hash table, calling callback function for each.
* Note: we use a separate mutex in this function to avoid a recursive
* locking deadlock (in case the callback calls _mesa_HashRemove()) and to
diff --git a/mesalib/src/mesa/main/hash.h b/mesalib/src/mesa/main/hash.h
index e3e8f492e..da3b9973d 100644
--- a/mesalib/src/mesa/main/hash.h
+++ b/mesalib/src/mesa/main/hash.h
@@ -59,9 +59,6 @@ _mesa_HashDeleteAll(struct _mesa_HashTable *table,
void (*callback)(GLuint key, void *data, void *userData),
void *userData);
-extern struct _mesa_HashTable *
-_mesa_HashClone(const struct _mesa_HashTable *table);
-
extern void
_mesa_HashWalk(const struct _mesa_HashTable *table,
void (*callback)(GLuint key, void *data, void *userData),
diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h
index 83425176a..e67e8074a 100644
--- a/mesalib/src/mesa/main/mtypes.h
+++ b/mesalib/src/mesa/main/mtypes.h
@@ -43,7 +43,6 @@
#include "glapi/glapi.h"
#include "math/m_matrix.h" /* GLmatrix */
#include "glsl/shader_enums.h"
-#include "util/simple_list.h" /* struct simple_node */
#include "main/formats.h" /* MESA_FORMAT_COUNT */
@@ -398,7 +397,6 @@ struct gl_config
{
GLboolean rgbMode;
GLboolean floatMode;
- GLboolean colorIndexMode; /* XXX is this used anywhere? */
GLuint doubleBufferMode;
GLuint stereoMode;
@@ -2275,16 +2273,10 @@ struct gl_vertex_program_state
*/
struct gl_geometry_program_state
{
- GLboolean Enabled; /**< GL_ARB_GEOMETRY_SHADER4 */
- GLboolean _Enabled; /**< Enabled and valid program? */
- struct gl_geometry_program *Current; /**< user-bound geometry program */
-
/** Currently enabled and valid program (including internal programs
* and compiled shader programs).
*/
struct gl_geometry_program *_Current;
-
- GLfloat Parameters[MAX_PROGRAM_ENV_PARAMS][4]; /**< Env params */
};
/**
@@ -2320,8 +2312,6 @@ struct gl_fragment_program_state
*/
struct gl_compute_program_state
{
- struct gl_compute_program *Current; /**< user-bound compute program */
-
/** Currently enabled and valid program (including internal programs
* and compiled shader programs).
*/
@@ -2728,7 +2718,7 @@ struct gl_shader_program
} Comp;
/* post-link info: */
- unsigned NumUserUniformStorage;
+ unsigned NumUniformStorage;
unsigned NumHiddenUniforms;
struct gl_uniform_storage *UniformStorage;
@@ -3004,7 +2994,6 @@ struct gl_shared_state
struct _mesa_HashTable *Programs; /**< All vertex/fragment programs */
struct gl_vertex_program *DefaultVertexProgram;
struct gl_fragment_program *DefaultFragmentProgram;
- struct gl_geometry_program *DefaultGeometryProgram;
/*@}*/
/* GL_ATI_fragment_shader */
@@ -3621,7 +3610,6 @@ struct gl_extensions
GLboolean ARB_depth_clamp;
GLboolean ARB_depth_texture;
GLboolean ARB_derivative_control;
- GLboolean ARB_direct_state_access;
GLboolean ARB_draw_buffers_blend;
GLboolean ARB_draw_elements_base_vertex;
GLboolean ARB_draw_indirect;
diff --git a/mesalib/src/mesa/main/pipelineobj.c b/mesalib/src/mesa/main/pipelineobj.c
index a33cdd139..0fefa7d56 100644
--- a/mesalib/src/mesa/main/pipelineobj.c
+++ b/mesalib/src/mesa/main/pipelineobj.c
@@ -553,12 +553,6 @@ _mesa_CreateProgramPipelines(GLsizei n, GLuint *pipelines)
{
GET_CURRENT_CONTEXT(ctx);
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glCreateProgramPipelines("
- "GL_ARB_direct_state_access is not supported)");
- return;
- }
-
create_program_pipelines(ctx, n, pipelines, true);
}
diff --git a/mesalib/src/mesa/main/program_resource.c b/mesalib/src/mesa/main/program_resource.c
index b15a13210..d857b84e6 100644
--- a/mesalib/src/mesa/main/program_resource.c
+++ b/mesalib/src/mesa/main/program_resource.c
@@ -220,12 +220,12 @@ _mesa_GetProgramResourceIndex(GLuint program, GLenum programInterface,
case GL_PROGRAM_INPUT:
case GL_PROGRAM_OUTPUT:
case GL_UNIFORM:
- case GL_UNIFORM_BLOCK:
case GL_TRANSFORM_FEEDBACK_VARYING:
- /* Validate name syntax for arrays. */
+ /* Validate name syntax for array variables */
if (!valid_program_resource_index_name(name))
return GL_INVALID_INDEX;
-
+ /* fall-through */
+ case GL_UNIFORM_BLOCK:
res = _mesa_program_resource_find_name(shProg, programInterface, name);
if (!res)
return GL_INVALID_INDEX;
diff --git a/mesalib/src/mesa/main/queryobj.c b/mesalib/src/mesa/main/queryobj.c
index 2784b4c05..5ff1b9532 100644
--- a/mesalib/src/mesa/main/queryobj.c
+++ b/mesalib/src/mesa/main/queryobj.c
@@ -284,13 +284,6 @@ _mesa_CreateQueries(GLenum target, GLsizei n, GLuint *ids)
{
GET_CURRENT_CONTEXT(ctx);
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glCreateQueries(GL_ARB_direct_state_access "
- "is not supported)");
- return;
- }
-
switch (target) {
case GL_SAMPLES_PASSED:
case GL_ANY_SAMPLES_PASSED:
diff --git a/mesalib/src/mesa/main/readpix.c b/mesalib/src/mesa/main/readpix.c
index df46f8361..a3357cd64 100644
--- a/mesalib/src/mesa/main/readpix.c
+++ b/mesalib/src/mesa/main/readpix.c
@@ -46,15 +46,18 @@
/**
* Return true if the conversion L=R+G+B is needed.
*/
-static GLboolean
-need_rgb_to_luminance_conversion(mesa_format texFormat, GLenum format)
+GLboolean
+_mesa_need_rgb_to_luminance_conversion(mesa_format texFormat, GLenum format)
{
GLenum baseTexFormat = _mesa_get_format_base_format(texFormat);
return (baseTexFormat == GL_RG ||
baseTexFormat == GL_RGB ||
baseTexFormat == GL_RGBA) &&
- (format == GL_LUMINANCE || format == GL_LUMINANCE_ALPHA);
+ (format == GL_LUMINANCE ||
+ format == GL_LUMINANCE_ALPHA ||
+ format == GL_LUMINANCE_INTEGER_EXT ||
+ format == GL_LUMINANCE_ALPHA_INTEGER_EXT);
}
@@ -102,7 +105,7 @@ get_readpixels_transfer_ops(const struct gl_context *ctx, mesa_format texFormat,
* have any effect anyway.
*/
if (_mesa_get_format_datatype(texFormat) == GL_UNSIGNED_NORMALIZED &&
- !need_rgb_to_luminance_conversion(texFormat, format)) {
+ !_mesa_need_rgb_to_luminance_conversion(texFormat, format)) {
transferOps &= ~IMAGE_CLAMP_BIT;
}
@@ -146,7 +149,7 @@ _mesa_readpixels_needs_slow_path(const struct gl_context *ctx, GLenum format,
default:
/* Color formats. */
- if (need_rgb_to_luminance_conversion(rb->Format, format)) {
+ if (_mesa_need_rgb_to_luminance_conversion(rb->Format, format)) {
return GL_TRUE;
}
@@ -418,7 +421,7 @@ read_rgba_pixels( struct gl_context *ctx,
const struct gl_pixelstore_attrib *packing )
{
GLbitfield transferOps;
- bool dst_is_integer, dst_is_luminance, needs_rebase;
+ bool dst_is_integer, convert_rgb_to_lum, needs_rebase;
int dst_stride, src_stride, rb_stride;
uint32_t dst_format, src_format;
GLubyte *dst, *map;
@@ -439,10 +442,8 @@ read_rgba_pixels( struct gl_context *ctx,
dst_is_integer = _mesa_is_enum_format_integer(format);
dst_stride = _mesa_image_row_stride(packing, width, format, type);
dst_format = _mesa_format_from_format_and_type(format, type);
- dst_is_luminance = format == GL_LUMINANCE ||
- format == GL_LUMINANCE_ALPHA ||
- format == GL_LUMINANCE_INTEGER_EXT ||
- format == GL_LUMINANCE_ALPHA_INTEGER_EXT;
+ convert_rgb_to_lum =
+ _mesa_need_rgb_to_luminance_conversion(rb->Format, format);
dst = (GLubyte *) _mesa_image_address2d(packing, pixels, width, height,
format, type, 0, 0);
@@ -490,7 +491,7 @@ read_rgba_pixels( struct gl_context *ctx,
*/
assert(!transferOps || (transferOps && !dst_is_integer));
- needs_rgba = transferOps || dst_is_luminance;
+ needs_rgba = transferOps || convert_rgb_to_lum;
rgba = NULL;
if (needs_rgba) {
uint32_t rgba_format;
@@ -563,7 +564,7 @@ read_rgba_pixels( struct gl_context *ctx,
* If the dst format is Luminance, we need to do the conversion by computing
* L=R+G+B values.
*/
- if (!dst_is_luminance) {
+ if (!convert_rgb_to_lum) {
_mesa_format_convert(dst, dst_format, dst_stride,
src, src_format, src_stride,
width, height,
diff --git a/mesalib/src/mesa/main/readpix.h b/mesalib/src/mesa/main/readpix.h
index 4bb35e17e..1636dd9ce 100644
--- a/mesalib/src/mesa/main/readpix.h
+++ b/mesalib/src/mesa/main/readpix.h
@@ -37,6 +37,9 @@ extern GLboolean
_mesa_readpixels_needs_slow_path(const struct gl_context *ctx, GLenum format,
GLenum type, GLboolean uses_blit);
+extern GLboolean
+_mesa_need_rgb_to_luminance_conversion(mesa_format texFormat, GLenum format);
+
extern void
_mesa_readpixels(struct gl_context *ctx,
GLint x, GLint y, GLsizei width, GLsizei height,
diff --git a/mesalib/src/mesa/main/samplerobj.c b/mesalib/src/mesa/main/samplerobj.c
index 60711a5b5..a3aacc66a 100644
--- a/mesalib/src/mesa/main/samplerobj.c
+++ b/mesalib/src/mesa/main/samplerobj.c
@@ -221,13 +221,6 @@ void GLAPIENTRY
_mesa_CreateSamplers(GLsizei count, GLuint *samplers)
{
GET_CURRENT_CONTEXT(ctx);
-
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glCreateSamplers("
- "GL_ARB_direct_state_access is not supported)");
- return;
- }
-
create_samplers(ctx, count, samplers, "glCreateSamplers");
}
diff --git a/mesalib/src/mesa/main/shader_query.cpp b/mesalib/src/mesa/main/shader_query.cpp
index 3445f89a3..a6246a39a 100644
--- a/mesalib/src/mesa/main/shader_query.cpp
+++ b/mesalib/src/mesa/main/shader_query.cpp
@@ -479,12 +479,20 @@ _mesa_GetFragDataLocation(GLuint program, const GLchar *name)
const char*
_mesa_program_resource_name(struct gl_program_resource *res)
{
+ const ir_variable *var;
switch (res->Type) {
case GL_UNIFORM_BLOCK:
return RESOURCE_UBO(res)->Name;
case GL_TRANSFORM_FEEDBACK_VARYING:
return RESOURCE_XFB(res)->Name;
case GL_PROGRAM_INPUT:
+ var = RESOURCE_VAR(res);
+ /* Special case gl_VertexIDMESA -> gl_VertexID. */
+ if (var->data.mode == ir_var_system_value &&
+ var->data.location == SYSTEM_VALUE_VERTEX_ID_ZERO_BASE) {
+ return "gl_VertexID";
+ }
+ /* fallthrough */
case GL_PROGRAM_OUTPUT:
return RESOURCE_VAR(res)->name;
case GL_UNIFORM:
@@ -539,6 +547,17 @@ struct gl_program_resource *
_mesa_program_resource_find_name(struct gl_shader_program *shProg,
GLenum programInterface, const char *name)
{
+ GET_CURRENT_CONTEXT(ctx);
+ const char *full_name = name;
+
+ /* When context has 'VertexID_is_zero_based' set, gl_VertexID has been
+ * lowered to gl_VertexIDMESA.
+ */
+ if (name && ctx->Const.VertexID_is_zero_based) {
+ if (strcmp(name, "gl_VertexID") == 0)
+ full_name = "gl_VertexIDMESA";
+ }
+
struct gl_program_resource *res = shProg->ProgramResourceList;
for (unsigned i = 0; i < shProg->NumProgramResourceList; i++, res++) {
if (res->Type != programInterface)
@@ -563,7 +582,7 @@ _mesa_program_resource_find_name(struct gl_shader_program *shProg,
break;
case GL_PROGRAM_INPUT:
case GL_PROGRAM_OUTPUT:
- if (array_index_of_resource(res, name) >= 0)
+ if (array_index_of_resource(res, full_name) >= 0)
return res;
break;
default:
@@ -728,6 +747,10 @@ program_resource_location(struct gl_shader_program *shProg,
return -1;
}
+ /* Built-in locations should report GL_INVALID_INDEX. */
+ if (is_gl_identifier(name))
+ return GL_INVALID_INDEX;
+
/* VERT_ATTRIB_GENERIC0 and FRAG_RESULT_DATA0 are decremented as these
* offsets are used internally to differentiate between built-in attributes
* and user-defined attributes.
diff --git a/mesalib/src/mesa/main/shaderapi.c b/mesalib/src/mesa/main/shaderapi.c
index a04b28711..a4296adf7 100644
--- a/mesalib/src/mesa/main/shaderapi.c
+++ b/mesalib/src/mesa/main/shaderapi.c
@@ -532,7 +532,7 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname,
/* True if geometry shaders (of the form that was adopted into GLSL 1.50
* and GL 3.2) are available in this context
*/
- const bool has_core_gs = _mesa_is_desktop_gl(ctx) && ctx->Version >= 32;
+ const bool has_core_gs = _mesa_has_geometry_shaders(ctx);
/* Are uniform buffer objects available in this context?
*/
@@ -569,13 +569,13 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname,
*params = _mesa_longest_attribute_name_length(shProg);
return;
case GL_ACTIVE_UNIFORMS:
- *params = shProg->NumUserUniformStorage - shProg->NumHiddenUniforms;
+ *params = shProg->NumUniformStorage - shProg->NumHiddenUniforms;
return;
case GL_ACTIVE_UNIFORM_MAX_LENGTH: {
unsigned i;
GLint max_len = 0;
const unsigned num_uniforms =
- shProg->NumUserUniformStorage - shProg->NumHiddenUniforms;
+ shProg->NumUniformStorage - shProg->NumHiddenUniforms;
for (i = 0; i < num_uniforms; i++) {
/* Add one for the terminating NUL character for a non-array, and
diff --git a/mesalib/src/mesa/main/shaderobj.c b/mesalib/src/mesa/main/shaderobj.c
index e42896036..110a18e1e 100644
--- a/mesalib/src/mesa/main/shaderobj.c
+++ b/mesalib/src/mesa/main/shaderobj.c
@@ -282,10 +282,10 @@ _mesa_clear_shader_program_data(struct gl_shader_program *shProg)
unsigned i;
if (shProg->UniformStorage) {
- for (i = 0; i < shProg->NumUserUniformStorage; ++i)
+ for (i = 0; i < shProg->NumUniformStorage; ++i)
_mesa_uniform_detach_all_driver_storage(&shProg->UniformStorage[i]);
ralloc_free(shProg->UniformStorage);
- shProg->NumUserUniformStorage = 0;
+ shProg->NumUniformStorage = 0;
shProg->UniformStorage = NULL;
}
diff --git a/mesalib/src/mesa/main/shared.c b/mesalib/src/mesa/main/shared.c
index 0b76cc012..d5ac9f1fb 100644
--- a/mesalib/src/mesa/main/shared.c
+++ b/mesalib/src/mesa/main/shared.c
@@ -313,7 +313,6 @@ free_shared_state(struct gl_context *ctx, struct gl_shared_state *shared)
_mesa_DeleteHashTable(shared->Programs);
_mesa_reference_vertprog(ctx, &shared->DefaultVertexProgram, NULL);
- _mesa_reference_geomprog(ctx, &shared->DefaultGeometryProgram, NULL);
_mesa_reference_fragprog(ctx, &shared->DefaultFragmentProgram, NULL);
_mesa_HashDeleteAll(shared->ATIShaders, delete_fragshader_cb, ctx);
diff --git a/mesalib/src/mesa/main/state.c b/mesalib/src/mesa/main/state.c
index 2657c532f..5b970081a 100644
--- a/mesalib/src/mesa/main/state.c
+++ b/mesalib/src/mesa/main/state.c
@@ -225,7 +225,7 @@ update_program(struct gl_context *ctx)
if (ctx->GeometryProgram._Current != prevGP) {
new_state |= _NEW_PROGRAM;
if (ctx->Driver.BindProgram) {
- ctx->Driver.BindProgram(ctx, MESA_GEOMETRY_PROGRAM,
+ ctx->Driver.BindProgram(ctx, GL_GEOMETRY_PROGRAM_NV,
(struct gl_program *) ctx->GeometryProgram._Current);
}
}
diff --git a/mesalib/src/mesa/main/texgetimage.c b/mesalib/src/mesa/main/texgetimage.c
index f582a7f78..92b4d6795 100644
--- a/mesalib/src/mesa/main/texgetimage.c
+++ b/mesalib/src/mesa/main/texgetimage.c
@@ -1108,13 +1108,6 @@ _mesa_GetTextureImage(GLuint texture, GLint level, GLenum format,
GLenum err;
GET_CURRENT_CONTEXT(ctx);
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glGetTextureImage(GL_ARB_direct_state_access "
- "is not supported)");
- return;
- }
-
/*
* This has been moved here because a format/type mismatch can cause a NULL
* texImage object, which in turn causes the mismatch error to be
@@ -1351,13 +1344,6 @@ _mesa_GetCompressedTextureImage(GLuint texture, GLint level,
GLint image_stride;
GET_CURRENT_CONTEXT(ctx);
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glGetCompressedTextureImage(GL_ARB_direct_state_access "
- "is not supported)");
- return;
- }
-
texObj = _mesa_lookup_texture_err(ctx, texture,
"glGetCompressedTextureImage");
if (!texObj)
diff --git a/mesalib/src/mesa/main/teximage.c b/mesalib/src/mesa/main/teximage.c
index 7616fd7ce..3d85615fa 100644
--- a/mesalib/src/mesa/main/teximage.c
+++ b/mesalib/src/mesa/main/teximage.c
@@ -222,7 +222,7 @@ _mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat )
}
}
- if (ctx->Extensions.ARB_stencil_texturing) {
+ if (ctx->Extensions.ARB_texture_stencil8) {
switch (internalFormat) {
case GL_STENCIL_INDEX:
case GL_STENCIL_INDEX1:
@@ -3624,13 +3624,6 @@ texturesubimage(struct gl_context *ctx, GLuint dims,
_mesa_lookup_enum_by_nr(format),
_mesa_lookup_enum_by_nr(type), pixels);
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glTextureSubImage%uD(GL_ARB_direct_state_access "
- "is not supported)", dims);
- return;
- }
-
/* Get the texture object by Name. */
texObj = _mesa_lookup_texture(ctx, texture);
if (!texObj) {
@@ -4190,12 +4183,6 @@ _mesa_CopyTextureSubImage1D(GLuint texture, GLint level,
const char *self = "glCopyTextureSubImage1D";
GET_CURRENT_CONTEXT(ctx);
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "%s(GL_ARB_direct_state_access is not supported)", self);
- return;
- }
-
texObj = _mesa_lookup_texture_err(ctx, texture, self);
if (!texObj)
return;
@@ -4220,12 +4207,6 @@ _mesa_CopyTextureSubImage2D(GLuint texture, GLint level,
const char *self = "glCopyTextureSubImage2D";
GET_CURRENT_CONTEXT(ctx);
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "%s(GL_ARB_direct_state_access is not supported)", self);
- return;
- }
-
texObj = _mesa_lookup_texture_err(ctx, texture, self);
if (!texObj)
return;
@@ -4253,12 +4234,6 @@ _mesa_CopyTextureSubImage3D(GLuint texture, GLint level,
const char *self = "glCopyTextureSubImage3D";
GET_CURRENT_CONTEXT(ctx);
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "%s(GL_ARB_direct_state_access is not supported)", self);
- return;
- }
-
texObj = _mesa_lookup_texture_err(ctx, texture, self);
if (!texObj)
return;
@@ -4854,13 +4829,6 @@ _mesa_CompressedTextureSubImage1D(GLuint texture, GLint level, GLint xoffset,
GET_CURRENT_CONTEXT(ctx);
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glCompressedTextureSubImage1D(GL_ARB_direct_state_access "
- "is not supported)");
- return;
- }
-
texObj = _mesa_lookup_texture_err(ctx, texture,
"glCompressedTextureSubImage1D");
if (!texObj)
@@ -4939,13 +4907,6 @@ _mesa_CompressedTextureSubImage2D(GLuint texture, GLint level, GLint xoffset,
GET_CURRENT_CONTEXT(ctx);
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glCompressedTextureSubImage2D(GL_ARB_direct_state_access "
- "is not supported)");
- return;
- }
-
texObj = _mesa_lookup_texture_err(ctx, texture,
"glCompressedTextureSubImage2D");
if (!texObj)
@@ -5024,13 +4985,6 @@ _mesa_CompressedTextureSubImage3D(GLuint texture, GLint level, GLint xoffset,
GET_CURRENT_CONTEXT(ctx);
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glCompressedTextureSubImage3D(GL_ARB_direct_state_access "
- "is not supported)");
- return;
- }
-
texObj = _mesa_lookup_texture_err(ctx, texture,
"glCompressedTextureSubImage3D");
if (!texObj)
@@ -5515,13 +5469,6 @@ _mesa_TextureBuffer(GLuint texture, GLenum internalFormat, GLuint buffer)
GET_CURRENT_CONTEXT(ctx);
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glTextureBuffer(GL_ARB_direct_state_access "
- "is not supported)");
- return;
- }
-
if (buffer) {
bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glTextureBuffer");
if (!bufObj)
@@ -5550,13 +5497,6 @@ _mesa_TextureBufferRange(GLuint texture, GLenum internalFormat, GLuint buffer,
GET_CURRENT_CONTEXT(ctx);
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glTextureBufferRange(GL_ARB_direct_state_access "
- "is not supported)");
- return;
- }
-
if (buffer) {
bufObj = _mesa_lookup_bufferobj_err(ctx, buffer,
"glTextureBufferRange");
@@ -5861,13 +5801,6 @@ _mesa_TextureStorage2DMultisample(GLuint texture, GLsizei samples,
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glTextureStorage2DMultisample(GL_ARB_direct_state_access "
- "is not supported)");
- return;
- }
-
texObj = _mesa_lookup_texture_err(ctx, texture,
"glTextureStorage2DMultisample");
if (!texObj)
@@ -5888,13 +5821,6 @@ _mesa_TextureStorage3DMultisample(GLuint texture, GLsizei samples,
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glTextureStorage3DMultisample(GL_ARB_direct_state_access "
- "is not supported)");
- return;
- }
-
/* Get the texture object by Name. */
texObj = _mesa_lookup_texture_err(ctx, texture,
"glTextureStorage3DMultisample");
diff --git a/mesalib/src/mesa/main/texobj.c b/mesalib/src/mesa/main/texobj.c
index d51e6954b..c563f1e74 100644
--- a/mesalib/src/mesa/main/texobj.c
+++ b/mesalib/src/mesa/main/texobj.c
@@ -1317,13 +1317,6 @@ _mesa_CreateTextures(GLenum target, GLsizei n, GLuint *textures)
GLint targetIndex;
GET_CURRENT_CONTEXT(ctx);
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glCreateTextures(GL_ARB_direct_state_access "
- "is not supported)");
- return;
- }
-
/*
* The 4.5 core profile spec (30.10.2014) doesn't specify what
* glCreateTextures should do with invalid targets, which was probably an
@@ -1815,13 +1808,6 @@ _mesa_BindTextureUnit(GLuint unit, GLuint texture)
_mesa_debug(ctx, "glBindTextureUnit %s %d\n",
_mesa_lookup_enum_by_nr(GL_TEXTURE0+unit), (GLint) texture);
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glBindTextureUnit(GL_ARB_direct_state_access "
- "is not supported)");
- return;
- }
-
/* Section 8.1 (Texture Objects) of the OpenGL 4.5 core profile spec
* (20141030) says:
* "When texture is zero, each of the targets enumerated at the
diff --git a/mesalib/src/mesa/main/texparam.c b/mesalib/src/mesa/main/texparam.c
index 1fa583002..d74134f41 100644
--- a/mesalib/src/mesa/main/texparam.c
+++ b/mesalib/src/mesa/main/texparam.c
@@ -1108,13 +1108,6 @@ _mesa_TextureParameterfv(GLuint texture, GLenum pname, const GLfloat *params)
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glTextureParameterfv(GL_ARB_direct_state_access "
- "is not supported)");
- return;
- }
-
texObj = get_texobj_by_name(ctx, texture, GL_FALSE);
if (!texObj) {
/* User passed a non-generated name. */
@@ -1131,13 +1124,6 @@ _mesa_TextureParameterf(GLuint texture, GLenum pname, GLfloat param)
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glTextureParameterf(GL_ARB_direct_state_access "
- "is not supported)");
- return;
- }
-
texObj = get_texobj_by_name(ctx, texture, GL_FALSE);
if (!texObj) {
/* User passed a non-generated name. */
@@ -1154,13 +1140,6 @@ _mesa_TextureParameteri(GLuint texture, GLenum pname, GLint param)
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glTextureParameteri(GL_ARB_direct_state_access "
- "is not supported)");
- return;
- }
-
texObj = get_texobj_by_name(ctx, texture, GL_FALSE);
if (!texObj) {
/* User passed a non-generated name. */
@@ -1178,13 +1157,6 @@ _mesa_TextureParameteriv(GLuint texture, GLenum pname,
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glTextureParameteriv(GL_ARB_direct_state_access "
- "is not supported)");
- return;
- }
-
texObj = get_texobj_by_name(ctx, texture, GL_FALSE);
if (!texObj) {
/* User passed a non-generated name. */
@@ -1202,13 +1174,6 @@ _mesa_TextureParameterIiv(GLuint texture, GLenum pname, const GLint *params)
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glTextureParameterIiv(GL_ARB_direct_state_access "
- "is not supported)");
- return;
- }
-
texObj = get_texobj_by_name(ctx, texture, GL_FALSE);
if (!texObj) {
/* User passed a non-generated name. */
@@ -1226,13 +1191,6 @@ _mesa_TextureParameterIuiv(GLuint texture, GLenum pname, const GLuint *params)
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glTextureParameterIuiv(GL_ARB_direct_state_access "
- "is not supported)");
- return;
- }
-
texObj = get_texobj_by_name(ctx, texture, GL_FALSE);
if (!texObj) {
/* User passed a non-generated name. */
@@ -1692,13 +1650,6 @@ _mesa_GetTextureLevelParameterfv(GLuint texture, GLint level,
GLint iparam;
GET_CURRENT_CONTEXT(ctx);
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glGetTextureLevelParameterfv(GL_ARB_direct_state_access "
- "is not supported)");
- return;
- }
-
texObj = _mesa_lookup_texture_err(ctx, texture,
"glGetTextureLevelParameterfv");
if (!texObj)
@@ -1717,13 +1668,6 @@ _mesa_GetTextureLevelParameteriv(GLuint texture, GLint level,
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glGetTextureLevelParameteriv(GL_ARB_direct_state_access "
- "is not supported)");
- return;
- }
-
texObj = _mesa_lookup_texture_err(ctx, texture,
"glGetTextureLevelParameteriv");
if (!texObj)
@@ -2283,13 +2227,6 @@ _mesa_GetTextureParameterfv(GLuint texture, GLenum pname, GLfloat *params)
struct gl_texture_object *obj;
GET_CURRENT_CONTEXT(ctx);
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glGetTextureParameterfv(GL_ARB_direct_state_access "
- "is not supported)");
- return;
- }
-
obj = get_texobj_by_name(ctx, texture, GL_TRUE);
if (!obj) {
/* User passed a non-generated name. */
@@ -2307,13 +2244,6 @@ _mesa_GetTextureParameteriv(GLuint texture, GLenum pname, GLint *params)
struct gl_texture_object *obj;
GET_CURRENT_CONTEXT(ctx);
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glGetTextureParameteriv(GL_ARB_direct_state_access "
- "is not supported)");
- return;
- }
-
obj = get_texobj_by_name(ctx, texture, GL_TRUE);
if (!obj) {
/* User passed a non-generated name. */
@@ -2331,13 +2261,6 @@ _mesa_GetTextureParameterIiv(GLuint texture, GLenum pname, GLint *params)
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glGetTextureParameterIiv(GL_ARB_direct_state_access "
- "is not supported)");
- return;
- }
-
texObj = get_texobj_by_name(ctx, texture, GL_TRUE);
if (!texObj) {
/* User passed a non-generated name. */
@@ -2356,13 +2279,6 @@ _mesa_GetTextureParameterIuiv(GLuint texture, GLenum pname, GLuint *params)
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glGetTextureParameterIuiv(GL_ARB_direct_state_access "
- "is not supported)");
- return;
- }
-
texObj = get_texobj_by_name(ctx, texture, GL_TRUE);
if (!texObj) {
/* User passed a non-generated name. */
diff --git a/mesalib/src/mesa/main/texstorage.c b/mesalib/src/mesa/main/texstorage.c
index dee74a825..53cb2c091 100644
--- a/mesalib/src/mesa/main/texstorage.c
+++ b/mesalib/src/mesa/main/texstorage.c
@@ -507,13 +507,6 @@ texturestorage(GLuint dims, GLuint texture, GLsizei levels,
_mesa_lookup_enum_by_nr(internalformat),
width, height, depth);
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glTextureStorage%uD(GL_ARB_direct_state_access "
- "is not supported)", dims);
- return;
- }
-
/* Check the format to make sure it is sized. */
if (!_mesa_is_legal_tex_storage_format(ctx, internalformat)) {
_mesa_error(ctx, GL_INVALID_ENUM,
diff --git a/mesalib/src/mesa/main/textureview.c b/mesalib/src/mesa/main/textureview.c
index cd87a27d2..6b0aed4ea 100644
--- a/mesalib/src/mesa/main/textureview.c
+++ b/mesalib/src/mesa/main/textureview.c
@@ -167,7 +167,7 @@ static const struct internal_format_class_info s3tc_compatible_internal_formats[
* \return VIEW_CLASS if internalformat found in table, false otherwise.
*/
static GLenum
-lookup_view_class(struct gl_context *ctx, GLenum internalformat)
+lookup_view_class(const struct gl_context *ctx, GLenum internalformat)
{
GLuint i;
@@ -176,9 +176,11 @@ lookup_view_class(struct gl_context *ctx, GLenum internalformat)
return compatible_internal_formats[i].view_class;
}
- if (ctx->Extensions.EXT_texture_compression_s3tc && ctx->Extensions.EXT_texture_sRGB) {
+ if (ctx->Extensions.EXT_texture_compression_s3tc &&
+ ctx->Extensions.EXT_texture_sRGB) {
for (i = 0; i < ARRAY_SIZE(s3tc_compatible_internal_formats); i++) {
- if (s3tc_compatible_internal_formats[i].internal_format == internalformat)
+ if (s3tc_compatible_internal_formats[i].internal_format
+ == internalformat)
return s3tc_compatible_internal_formats[i].view_class;
}
}
@@ -226,7 +228,8 @@ initialize_texture_fields(struct gl_context *ctx,
0, internalFormat, texFormat);
}
- _mesa_next_mipmap_level_size(target, 0, levelWidth, levelHeight, levelDepth,
+ _mesa_next_mipmap_level_size(target, 0,
+ levelWidth, levelHeight, levelDepth,
&levelWidth, &levelHeight, &levelDepth);
}
@@ -320,8 +323,8 @@ target_valid(struct gl_context *ctx, GLenum origTarget, GLenum newTarget)
* If an error is found, record it with _mesa_error()
* \return false if any error, true otherwise.
*/
-GLboolean
-_mesa_texture_view_compatible_format(struct gl_context *ctx,
+bool
+_mesa_texture_view_compatible_format(const struct gl_context *ctx,
GLenum origInternalFormat,
GLenum newInternalFormat)
{
@@ -334,15 +337,16 @@ _mesa_texture_view_compatible_format(struct gl_context *ctx,
* or an INVALID_OPERATION error is generated.
*/
if (origInternalFormat == newInternalFormat)
- return GL_TRUE;
+ return true;
origViewClass = lookup_view_class(ctx, origInternalFormat);
newViewClass = lookup_view_class(ctx, newInternalFormat);
if ((origViewClass == newViewClass) && origViewClass != false)
- return GL_TRUE;
+ return true;
- return GL_FALSE;
+ return false;
}
+
/**
* Helper function for TexStorage and teximagemultisample to set immutable
* texture state needed by ARB_texture_view.
@@ -357,17 +361,19 @@ _mesa_set_texture_view_state(struct gl_context *ctx,
/* Get a reference to what will become this View's base level */
texImage = _mesa_select_tex_image(texObj, target, 0);
- /* When an immutable texture is created via glTexStorage or glTexImageMultisample,
+ /* When an immutable texture is created via glTexStorage or
+ * glTexImageMultisample,
* TEXTURE_IMMUTABLE_FORMAT becomes TRUE.
* TEXTURE_IMMUTABLE_LEVELS and TEXTURE_VIEW_NUM_LEVELS become levels.
* If the texture target is TEXTURE_1D_ARRAY then
* TEXTURE_VIEW_NUM_LAYERS becomes height.
* If the texture target is TEXTURE_2D_ARRAY, TEXTURE_CUBE_MAP_ARRAY,
- * or TEXTURE_2D_MULTISAMPLE_ARRAY then TEXTURE_VIEW_NUM_LAYERS becomes depth.
+ * or TEXTURE_2D_MULTISAMPLE_ARRAY then TEXTURE_VIEW_NUM_LAYERS becomes
+ * depth.
* If the texture target is TEXTURE_CUBE_MAP, then
* TEXTURE_VIEW_NUM_LAYERS becomes 6.
* For any other texture target, TEXTURE_VIEW_NUM_LAYERS becomes 1.
- *
+ *
* ARB_texture_multisample: Multisample textures do
* not have multiple image levels.
*/
@@ -401,7 +407,6 @@ _mesa_set_texture_view_state(struct gl_context *ctx,
case GL_TEXTURE_CUBE_MAP:
texObj->NumLayers = 6;
break;
-
}
}
@@ -435,16 +440,20 @@ _mesa_TextureView(GLuint texture, GLenum target, GLuint origtexture,
minlevel, numlevels, minlayer, numlayers);
if (origtexture == 0) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glTextureView(origtexture = %u)", origtexture);
+ _mesa_error(ctx, GL_INVALID_VALUE, "glTextureView(origtexture = %u)",
+ origtexture);
return;
}
/* Need original texture information to validate arguments */
origTexObj = _mesa_lookup_texture(ctx, origtexture);
- /* If <origtexture> is not the name of a texture, INVALID_VALUE is generated. */
+ /* If <origtexture> is not the name of a texture, INVALID_VALUE
+ * is generated.
+ */
if (!origTexObj) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glTextureView(origtexture = %u)", origtexture);
+ _mesa_error(ctx, GL_INVALID_VALUE, "glTextureView(origtexture = %u)",
+ origtexture);
return;
}
@@ -452,7 +461,8 @@ _mesa_TextureView(GLuint texture, GLenum target, GLuint origtexture,
* INVALID_OPERATION is generated.
*/
if (!origTexObj->Immutable) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glTextureView(origtexture not immutable)");
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTextureView(origtexture not immutable)");
return;
}
@@ -467,7 +477,8 @@ _mesa_TextureView(GLuint texture, GLenum target, GLuint origtexture,
*/
texObj = _mesa_lookup_texture(ctx, texture);
if (texObj == NULL) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glTextureView(texture = %u non-gen name)", texture);
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTextureView(texture = %u non-gen name)", texture);
return;
}
@@ -475,7 +486,8 @@ _mesa_TextureView(GLuint texture, GLenum target, GLuint origtexture,
* the error INVALID_OPERATION is generated.
*/
if (texObj->Target) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glTextureView(texture = %u already bound)", texture);
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTextureView(texture = %u already bound)", texture);
return;
}
@@ -484,33 +496,35 @@ _mesa_TextureView(GLuint texture, GLenum target, GLuint origtexture,
return; /* error was recorded */
}
- /* minlevel and minlayer are relative to the view of origtexture
+ /* minlevel and minlayer are relative to the view of origtexture.
* If minlevel or minlayer is greater than level or layer, respectively,
- * of origtexture return INVALID_VALUE.
+ * return INVALID_VALUE.
*/
newViewMinLevel = origTexObj->MinLevel + minlevel;
newViewMinLayer = origTexObj->MinLayer + minlayer;
if (newViewMinLevel >= (origTexObj->MinLevel + origTexObj->NumLevels)) {
_mesa_error(ctx, GL_INVALID_VALUE,
- "glTextureView(new minlevel (%d) > orig minlevel (%d) + orig numlevels (%d))",
+ "glTextureView(new minlevel (%d) > orig minlevel (%d)"
+ " + orig numlevels (%d))",
newViewMinLevel, origTexObj->MinLevel, origTexObj->NumLevels);
return;
}
if (newViewMinLayer >= (origTexObj->MinLayer + origTexObj->NumLayers)) {
_mesa_error(ctx, GL_INVALID_VALUE,
- "glTextureView(new minlayer (%d) > orig minlayer (%d) + orig numlayers (%d))",
+ "glTextureView(new minlayer (%d) > orig minlayer (%d)"
+ " + orig numlayers (%d))",
newViewMinLayer, origTexObj->MinLayer, origTexObj->NumLayers);
return;
}
if (!_mesa_texture_view_compatible_format(ctx,
- origTexObj->Image[0][0]->InternalFormat,
- internalformat)) {
+ origTexObj->Image[0][0]->InternalFormat,
+ internalformat)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glTextureView(internalformat %s not compatible with origtexture %s)",
- _mesa_lookup_enum_by_nr(internalformat),
- _mesa_lookup_enum_by_nr(origTexObj->Image[0][0]->InternalFormat));
+ "glTextureView(internalformat %s not compatible with origtexture %s)",
+ _mesa_lookup_enum_by_nr(internalformat),
+ _mesa_lookup_enum_by_nr(origTexObj->Image[0][0]->InternalFormat));
return;
}
@@ -569,14 +583,16 @@ _mesa_TextureView(GLuint texture, GLenum target, GLuint origtexture,
dimensionsOK = _mesa_legal_texture_dimensions(ctx, target, 0,
width, height, depth, 0);
if (!dimensionsOK) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glTextureView(invalid width or height or depth)");
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTextureView(invalid width or height or depth)");
return;
}
sizeOK = ctx->Driver.TestProxyTexImage(ctx, target, 0, texFormat,
width, height, depth, 0);
if (!sizeOK) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glTextureView(invalid texture size)");
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTextureView(invalid texture size)");
return;
}
@@ -591,17 +607,19 @@ _mesa_TextureView(GLuint texture, GLenum target, GLuint origtexture,
case GL_TEXTURE_RECTANGLE:
case GL_TEXTURE_2D_MULTISAMPLE:
if (numlayers != 1) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glTextureView(numlayers %d != 1)", numlayers);
+ _mesa_error(ctx, GL_INVALID_VALUE, "glTextureView(numlayers %d != 1)",
+ numlayers);
return;
}
break;
case GL_TEXTURE_CUBE_MAP:
- /* If the new texture's target is TEXTURE_CUBE_MAP, the clamped <numlayers>
- * must be equal to 6.
+ /* If the new texture's target is TEXTURE_CUBE_MAP, the clamped
+ * <numlayers> must be equal to 6.
*/
if (newViewNumLayers != 6) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glTextureView(clamped numlayers %d != 6)",
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glTextureView(clamped numlayers %d != 6)",
newViewNumLayers);
return;
}
@@ -615,7 +633,8 @@ _mesa_TextureView(GLuint texture, GLenum target, GLuint origtexture,
*/
if ((newViewNumLayers % 6) != 0) {
_mesa_error(ctx, GL_INVALID_VALUE,
- "glTextureView(clamped numlayers %d is not a multiple of 6)",
+ "glTextureView(clamped numlayers %d is not"
+ " a multiple of 6)",
newViewNumLayers);
return;
}
@@ -628,7 +647,8 @@ _mesa_TextureView(GLuint texture, GLenum target, GLuint origtexture,
*/
if ((target == GL_TEXTURE_CUBE_MAP || target == GL_TEXTURE_CUBE_MAP_ARRAY) &&
(origTexImage->Width != origTexImage->Height)) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glTextureView(origtexture width (%d) != height (%d))",
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTextureView(origtexture width (%d) != height (%d))",
origTexImage->Width, origTexImage->Height);
return;
}
@@ -662,7 +682,8 @@ _mesa_TextureView(GLuint texture, GLenum target, GLuint origtexture,
texObj->ImmutableLevels = origTexObj->ImmutableLevels;
texObj->Target = target;
- if (ctx->Driver.TextureView != NULL && !ctx->Driver.TextureView(ctx, texObj, origTexObj)) {
+ if (ctx->Driver.TextureView != NULL &&
+ !ctx->Driver.TextureView(ctx, texObj, origTexObj)) {
return; /* driver recorded error */
}
}
diff --git a/mesalib/src/mesa/main/textureview.h b/mesalib/src/mesa/main/textureview.h
index 549a13cd8..59e24b68d 100644
--- a/mesalib/src/mesa/main/textureview.h
+++ b/mesalib/src/mesa/main/textureview.h
@@ -29,8 +29,8 @@
#ifndef TEXTUREVIEW_H
#define TEXTUREVIEW_H
-GLboolean
-_mesa_texture_view_compatible_format(struct gl_context *ctx,
+bool
+_mesa_texture_view_compatible_format(const struct gl_context *ctx,
GLenum origInternalFormat,
GLenum newInternalFormat);
@@ -41,7 +41,8 @@ _mesa_TextureView(GLuint texture, GLenum target, GLuint origtexture,
GLuint minlayer, GLuint numlayers);
extern void
-_mesa_set_texture_view_state(struct gl_context *ctx, struct gl_texture_object *texObj,
- GLenum target, GLuint levels);
+_mesa_set_texture_view_state(struct gl_context *ctx,
+ struct gl_texture_object *texObj,
+ GLenum target, GLuint levels);
#endif /* TEXTUREVIEW_H */
diff --git a/mesalib/src/mesa/main/transformfeedback.c b/mesalib/src/mesa/main/transformfeedback.c
index 642fa9647..103011ce5 100644
--- a/mesalib/src/mesa/main/transformfeedback.c
+++ b/mesalib/src/mesa/main/transformfeedback.c
@@ -706,13 +706,6 @@ _mesa_TransformFeedbackBufferBase(GLuint xfb, GLuint index, GLuint buffer)
struct gl_transform_feedback_object *obj;
struct gl_buffer_object *bufObj;
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glTransformFeedbackBufferBase(GL_ARB_direct_state_access "
- "is not supported)");
- return;
- }
-
obj = lookup_transform_feedback_object_err(ctx, xfb,
"glTransformFeedbackBufferBase");
if(!obj) {
@@ -736,13 +729,6 @@ _mesa_TransformFeedbackBufferRange(GLuint xfb, GLuint index, GLuint buffer,
struct gl_transform_feedback_object *obj;
struct gl_buffer_object *bufObj;
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glTransformFeedbackBufferRange(GL_ARB_direct_state_access "
- "is not supported)");
- return;
- }
-
obj = lookup_transform_feedback_object_err(ctx, xfb,
"glTransformFeedbackBufferRange");
if(!obj) {
@@ -1059,13 +1045,6 @@ _mesa_CreateTransformFeedbacks(GLsizei n, GLuint *names)
{
GET_CURRENT_CONTEXT(ctx);
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glCreateTransformFeedbacks(GL_ARB_direct_state_access "
- "is not supported)");
- return;
- }
-
create_transform_feedbacks(ctx, n, names, true);
}
@@ -1236,13 +1215,6 @@ _mesa_GetTransformFeedbackiv(GLuint xfb, GLenum pname, GLint *param)
struct gl_transform_feedback_object *obj;
GET_CURRENT_CONTEXT(ctx);
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glGetTransformFeedbackiv(GL_ARB_direct_state_access "
- "is not supported)");
- return;
- }
-
obj = lookup_transform_feedback_object_err(ctx, xfb,
"glGetTransformFeedbackiv");
if(!obj) {
@@ -1269,13 +1241,6 @@ _mesa_GetTransformFeedbacki_v(GLuint xfb, GLenum pname, GLuint index,
struct gl_transform_feedback_object *obj;
GET_CURRENT_CONTEXT(ctx);
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glGetTransformFeedbacki_v(GL_ARB_direct_state_access "
- "is not supported)");
- return;
- }
-
obj = lookup_transform_feedback_object_err(ctx, xfb,
"glGetTransformFeedbacki_v");
if(!obj) {
@@ -1305,13 +1270,6 @@ _mesa_GetTransformFeedbacki64_v(GLuint xfb, GLenum pname, GLuint index,
struct gl_transform_feedback_object *obj;
GET_CURRENT_CONTEXT(ctx);
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glGetTransformFeedbacki64_v(GL_ARB_direct_state_access "
- "is not supported)");
- return;
- }
-
obj = lookup_transform_feedback_object_err(ctx, xfb,
"glGetTransformFeedbacki64_v");
if(!obj) {
diff --git a/mesalib/src/mesa/main/uniform_query.cpp b/mesalib/src/mesa/main/uniform_query.cpp
index 728bd1bac..cab5083e8 100644
--- a/mesalib/src/mesa/main/uniform_query.cpp
+++ b/mesalib/src/mesa/main/uniform_query.cpp
@@ -237,6 +237,13 @@ validate_uniform_parameters(struct gl_context *ctx,
struct gl_uniform_storage *const uni = shProg->UniformRemapTable[location];
+ /* Even though no location is assigned to a built-in uniform and this
+ * function should already have returned NULL, this test makes it explicit
+ * that we are not allowing to update the value of a built-in.
+ */
+ if (uni->builtin)
+ return NULL;
+
if (uni->array_elements == 0) {
if (count > 1) {
_mesa_error(ctx, GL_INVALID_OPERATION,
@@ -1028,6 +1035,10 @@ _mesa_get_uniform_location(struct gl_shader_program *shProg,
if (!found)
return GL_INVALID_INDEX;
+ /* If the uniform is built-in, fail. */
+ if (shProg->UniformStorage[location].builtin)
+ return GL_INVALID_INDEX;
+
/* If the uniform is an array, fail if the index is out of bounds.
* (A negative index is caught above.) This also fails if the uniform
* is not an array, but the user is trying to index it, because
@@ -1047,7 +1058,7 @@ _mesa_sampler_uniforms_are_valid(const struct gl_shader_program *shProg,
char *errMsg, size_t errMsgLength)
{
/* Shader does not have samplers. */
- if (shProg->NumUserUniformStorage == 0)
+ if (shProg->NumUniformStorage == 0)
return true;
if (!shProg->SamplersValidated) {
@@ -1087,7 +1098,7 @@ _mesa_sampler_uniforms_pipeline_are_valid(struct gl_pipeline_object *pipeline)
if (!shProg[idx])
continue;
- for (unsigned i = 0; i < shProg[idx]->NumUserUniformStorage; i++) {
+ for (unsigned i = 0; i < shProg[idx]->NumUniformStorage; i++) {
const struct gl_uniform_storage *const storage =
&shProg[idx]->UniformStorage[i];
const glsl_type *const t = (storage->type->is_array())
diff --git a/mesalib/src/mesa/main/uniforms.h b/mesalib/src/mesa/main/uniforms.h
index 55fa2357e..bd7b05e20 100644
--- a/mesalib/src/mesa/main/uniforms.h
+++ b/mesalib/src/mesa/main/uniforms.h
@@ -343,10 +343,6 @@ void GLAPIENTRY
_mesa_ProgramUniformMatrix4x3dv(GLuint program, GLint location, GLsizei count,
GLboolean transpose, const GLdouble *value);
-long
-_mesa_parse_program_resource_name(const GLchar *name,
- const GLchar **out_base_name_end);
-
unsigned
_mesa_get_uniform_location(struct gl_shader_program *shProg,
const GLchar *name, unsigned *offset);
diff --git a/mesalib/src/mesa/main/varray.c b/mesalib/src/mesa/main/varray.c
index da6bbce52..7389037ae 100644
--- a/mesalib/src/mesa/main/varray.c
+++ b/mesalib/src/mesa/main/varray.c
@@ -777,13 +777,6 @@ _mesa_EnableVertexArrayAttrib(GLuint vaobj, GLuint index)
GET_CURRENT_CONTEXT(ctx);
struct gl_vertex_array_object *vao;
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glEnableVertexArrayAttrib(GL_ARB_direct_state_access "
- "is not supported");
- return;
- }
-
/* The ARB_direct_state_access specification says:
*
* "An INVALID_OPERATION error is generated by EnableVertexArrayAttrib
@@ -837,13 +830,6 @@ _mesa_DisableVertexArrayAttrib(GLuint vaobj, GLuint index)
GET_CURRENT_CONTEXT(ctx);
struct gl_vertex_array_object *vao;
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glDisableVertexArrayAttrib(GL_ARB_direct_state_access "
- "is not supported");
- return;
- }
-
/* The ARB_direct_state_access specification says:
*
* "An INVALID_OPERATION error is generated by EnableVertexArrayAttrib
@@ -1108,13 +1094,6 @@ _mesa_GetVertexArrayIndexediv(GLuint vaobj, GLuint index,
GET_CURRENT_CONTEXT(ctx);
struct gl_vertex_array_object *vao;
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glGetVertexArrayIndexediv(GL_ARB_direct_state_access "
- "is not supported");
- return;
- }
-
/* The ARB_direct_state_access specification says:
*
* "An INVALID_OPERATION error is generated if <vaobj> is not
@@ -1178,14 +1157,6 @@ _mesa_GetVertexArrayIndexed64iv(GLuint vaobj, GLuint index,
GET_CURRENT_CONTEXT(ctx);
struct gl_vertex_array_object *vao;
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glGetVertexArrayIndexed64iv(GL_ARB_direct_state_access "
- "is not supported");
- return;
- }
-
-
/* The ARB_direct_state_access specification says:
*
* "An INVALID_OPERATION error is generated if <vaobj> is not
@@ -1774,13 +1745,6 @@ _mesa_VertexArrayVertexBuffer(GLuint vaobj, GLuint bindingIndex, GLuint buffer,
GET_CURRENT_CONTEXT(ctx);
struct gl_vertex_array_object *vao;
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glVertexArrayVertexBuffer(GL_ARB_direct_state_access "
- "is not supported");
- return;
- }
-
/* The ARB_direct_state_access specification says:
*
* "An INVALID_OPERATION error is generated by VertexArrayVertexBuffer
@@ -1946,14 +1910,6 @@ _mesa_VertexArrayVertexBuffers(GLuint vaobj, GLuint first, GLsizei count,
GET_CURRENT_CONTEXT(ctx);
struct gl_vertex_array_object *vao;
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glVertexArrayVertexBuffers(GL_ARB_direct_state_access "
- "is not supported");
- return;
- }
-
-
/* The ARB_direct_state_access specification says:
*
* "An INVALID_OPERATION error is generated by VertexArrayVertexBuffer
@@ -2062,12 +2018,6 @@ vertex_array_attrib_format(GLuint vaobj, GLuint attribIndex, GLint size,
GET_CURRENT_CONTEXT(ctx);
struct gl_vertex_array_object *vao;
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "%s(GL_ARB_direct_state_access is not supported", func);
- return;
- }
-
ASSERT_OUTSIDE_BEGIN_END(ctx);
/* The ARB_direct_state_access spec says:
@@ -2205,13 +2155,6 @@ _mesa_VertexArrayAttribBinding(GLuint vaobj, GLuint attribIndex, GLuint bindingI
GET_CURRENT_CONTEXT(ctx);
struct gl_vertex_array_object *vao;
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glVertexArrayAttribBinding(GL_ARB_direct_state_access "
- "is not supported");
- return;
- }
-
/* The ARB_direct_state_access specification says:
*
* "An INVALID_OPERATION error is generated by VertexArrayAttribBinding
@@ -2286,13 +2229,6 @@ _mesa_VertexArrayBindingDivisor(GLuint vaobj, GLuint bindingIndex, GLuint diviso
struct gl_vertex_array_object *vao;
GET_CURRENT_CONTEXT(ctx);
- if (!ctx->Extensions.ARB_direct_state_access) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glVertexArrayBindingDivisor(GL_ARB_direct_state_access "
- "is not supported");
- return;
- }
-
/* The ARB_direct_state_access specification says:
*
* "An INVALID_OPERATION error is generated by VertexArrayBindingDivisor
diff --git a/mesalib/src/mesa/main/version.c b/mesalib/src/mesa/main/version.c
index 699a0de46..60c76040e 100644
--- a/mesalib/src/mesa/main/version.c
+++ b/mesalib/src/mesa/main/version.c
@@ -51,15 +51,20 @@ check_for_ending(const char *string, const char *ending)
* fwd_context is only valid if version > 0
*/
static void
-get_gl_override(int *version, bool *fwd_context, bool *compat_context)
+get_gl_override(gl_api api, int *version, bool *fwd_context,
+ bool *compat_context)
{
- const char *env_var = "MESA_GL_VERSION_OVERRIDE";
+ const char *env_var = (api == API_OPENGL_CORE || api == API_OPENGL_COMPAT)
+ ? "MESA_GL_VERSION_OVERRIDE" : "MESA_GLES_VERSION_OVERRIDE";
const char *version_str;
int major, minor, n;
static int override_version = -1;
static bool fc_suffix = false;
static bool compat_suffix = false;
+ if (api == API_OPENGLES)
+ goto exit;
+
if (override_version < 0) {
override_version = 0;
@@ -75,7 +80,12 @@ get_gl_override(int *version, bool *fwd_context, bool *compat_context)
override_version = 0;
} else {
override_version = major * 10 + minor;
- if (override_version < 30 && fc_suffix) {
+
+ /* There is no such thing as compatibility or forward-compatible for
+ * OpenGL ES 2.0 or 3.x APIs.
+ */
+ if ((override_version < 30 && fc_suffix) ||
+ (api == API_OPENGLES2 && (fc_suffix || compat_suffix))) {
fprintf(stderr, "error: invalid value for %s: %s\n",
env_var, version_str);
}
@@ -83,6 +93,7 @@ get_gl_override(int *version, bool *fwd_context, bool *compat_context)
}
}
+exit:
*version = override_version;
*fwd_context = fc_suffix;
*compat_context = compat_suffix;
@@ -130,18 +141,26 @@ _mesa_override_gl_version_contextless(struct gl_constants *consts,
int version;
bool fwd_context, compat_context;
- get_gl_override(&version, &fwd_context, &compat_context);
+ get_gl_override(*apiOut, &version, &fwd_context, &compat_context);
if (version > 0) {
*versionOut = version;
- if (version >= 30 && fwd_context) {
- *apiOut = API_OPENGL_CORE;
- consts->ContextFlags |= GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT;
- } else if (version >= 31 && !compat_context) {
- *apiOut = API_OPENGL_CORE;
- } else {
- *apiOut = API_OPENGL_COMPAT;
+
+ /* If the API is a desktop API, adjust the context flags. We may also
+ * need to modify the API depending on the version. For example, Mesa
+ * does not support a GL 3.3 compatibility profile.
+ */
+ if (*apiOut == API_OPENGL_CORE || *apiOut == API_OPENGL_COMPAT) {
+ if (version >= 30 && fwd_context) {
+ *apiOut = API_OPENGL_CORE;
+ consts->ContextFlags |= GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT;
+ } else if (version >= 31 && !compat_context) {
+ *apiOut = API_OPENGL_CORE;
+ } else {
+ *apiOut = API_OPENGL_COMPAT;
+ }
}
+
return true;
}
return false;
@@ -157,22 +176,6 @@ _mesa_override_gl_version(struct gl_context *ctx)
}
/**
- * Returns the gl override value
- *
- * version > 0 indicates there is an override requested
- */
-int
-_mesa_get_gl_version_override(void)
-{
- int version;
- bool fwd_context, compat_context;
-
- get_gl_override(&version, &fwd_context, &compat_context);
-
- return version;
-}
-
-/**
* Override the context's GLSL version if the environment variable
* MESA_GLSL_VERSION_OVERRIDE is set. Valid values for
* MESA_GLSL_VERSION_OVERRIDE are integers, such as "130".
@@ -433,7 +436,23 @@ compute_version_es2(const struct gl_extensions *extensions)
extensions->EXT_texture_snorm &&
extensions->NV_primitive_restart &&
extensions->OES_depth_texture_cube_map);
- if (ver_3_0) {
+ const bool ver_3_1 = (ver_3_0 &&
+ extensions->ARB_arrays_of_arrays &&
+ extensions->ARB_compute_shader &&
+ extensions->ARB_draw_indirect &&
+ false /*extensions->ARB_framebuffer_no_attachments*/ &&
+ extensions->ARB_shader_atomic_counters &&
+ extensions->ARB_shader_image_load_store &&
+ false /*extensions->ARB_shader_image_size*/ &&
+ false /*extensions->ARB_shader_storage_buffer_object*/ &&
+ extensions->ARB_shading_language_packing &&
+ extensions->ARB_stencil_texturing &&
+ extensions->ARB_gpu_shader5 &&
+ extensions->EXT_shader_integer_mix);
+
+ if (ver_3_1) {
+ return 31;
+ } else if (ver_3_0) {
return 30;
} else if (ver_2_0) {
return 20;
diff --git a/mesalib/src/mesa/main/version.h b/mesalib/src/mesa/main/version.h
index 450a0e31d..ee7cb7501 100644
--- a/mesalib/src/mesa/main/version.h
+++ b/mesalib/src/mesa/main/version.h
@@ -47,7 +47,4 @@ _mesa_override_gl_version(struct gl_context *ctx);
extern void
_mesa_override_glsl_version(struct gl_constants *consts);
-extern int
-_mesa_get_gl_version_override(void);
-
#endif /* VERSION_H */
diff --git a/mesalib/src/mesa/main/vtxfmt.c b/mesalib/src/mesa/main/vtxfmt.c
index d7ef7e278..81bf4c589 100644
--- a/mesalib/src/mesa/main/vtxfmt.c
+++ b/mesalib/src/mesa/main/vtxfmt.c
@@ -207,7 +207,7 @@ install_vtxfmt(struct gl_context *ctx, struct _glapi_table *tab,
SET_VertexAttribP4uiv(tab, vfmt->VertexAttribP4uiv);
}
- if (_mesa_is_desktop_gl(ctx)) {
+ if (ctx->API == API_OPENGL_CORE) {
SET_VertexAttribL1d(tab, vfmt->VertexAttribL1d);
SET_VertexAttribL2d(tab, vfmt->VertexAttribL2d);
SET_VertexAttribL3d(tab, vfmt->VertexAttribL3d);
diff --git a/mesalib/src/mesa/program/dummy_errors.c b/mesalib/src/mesa/program/dummy_errors.c
new file mode 100644
index 000000000..d69f54d1d
--- /dev/null
+++ b/mesalib/src/mesa/program/dummy_errors.c
@@ -0,0 +1,30 @@
+/*
+ * Copyright © 2014 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+#include <stdio.h>
+#include "main/errors.h"
+
+void
+_mesa_error_no_memory(const char *caller)
+{
+ fprintf(stderr, "Mesa error: out of memory in %s", caller);
+}
diff --git a/mesalib/src/mesa/program/ir_to_mesa.cpp b/mesalib/src/mesa/program/ir_to_mesa.cpp
index 3dcb53702..18e3bc5d5 100644
--- a/mesalib/src/mesa/program/ir_to_mesa.cpp
+++ b/mesalib/src/mesa/program/ir_to_mesa.cpp
@@ -262,6 +262,7 @@ public:
virtual void visit(ir_if *);
virtual void visit(ir_emit_vertex *);
virtual void visit(ir_end_primitive *);
+ virtual void visit(ir_barrier *);
/*@}*/
src_reg result;
@@ -405,7 +406,7 @@ ir_to_mesa_visitor::emit_dp(ir_instruction *ir,
dst_reg dst, src_reg src0, src_reg src1,
unsigned elements)
{
- static const gl_inst_opcode dot_opcodes[] = {
+ static const enum prog_opcode dot_opcodes[] = {
OPCODE_DP2, OPCODE_DP3, OPCODE_DP4
};
@@ -2117,6 +2118,12 @@ ir_to_mesa_visitor::visit(ir_end_primitive *)
assert(!"Geometry shaders not supported.");
}
+void
+ir_to_mesa_visitor::visit(ir_barrier *)
+{
+ unreachable("GLSL barrier() not supported.");
+}
+
ir_to_mesa_visitor::ir_to_mesa_visitor()
{
result.file = PROGRAM_UNDEFINED;
@@ -2406,9 +2413,14 @@ _mesa_associate_uniform_storage(struct gl_context *ctx,
if (!found)
continue;
+ struct gl_uniform_storage *storage =
+ &shader_program->UniformStorage[location];
+
+ /* Do not associate any uniform storage to built-in uniforms */
+ if (storage->builtin)
+ continue;
+
if (location != last_location) {
- struct gl_uniform_storage *storage =
- &shader_program->UniformStorage[location];
enum gl_uniform_driver_format format = uniform_native;
unsigned columns = 0;
@@ -2720,7 +2732,7 @@ get_mesa_program(struct gl_context *ctx,
mesa_inst->Opcode = inst->op;
mesa_inst->CondUpdate = inst->cond_update;
if (inst->saturate)
- mesa_inst->SaturateMode = SATURATE_ZERO_ONE;
+ mesa_inst->Saturate = GL_TRUE;
mesa_inst->DstReg.File = inst->dst.file;
mesa_inst->DstReg.Index = inst->dst.index;
mesa_inst->DstReg.CondMask = inst->dst.cond_mask;
diff --git a/mesalib/src/mesa/program/prog_execute.c b/mesalib/src/mesa/program/prog_execute.c
index 16e8e340d..46260b548 100644
--- a/mesalib/src/mesa/program/prog_execute.c
+++ b/mesalib/src/mesa/program/prog_execute.c
@@ -397,7 +397,7 @@ store_vector4(const struct prog_instruction *inst,
struct gl_program_machine *machine, const GLfloat value[4])
{
const struct prog_dst_register *dstReg = &(inst->DstReg);
- const GLboolean clamp = inst->SaturateMode == SATURATE_ZERO_ONE;
+ const GLboolean clamp = inst->Saturate;
GLuint writeMask = dstReg->WriteMask;
GLfloat clampedValue[4];
GLfloat *dst = get_dst_register_pointer(dstReg, machine);
diff --git a/mesalib/src/mesa/program/prog_instruction.c b/mesalib/src/mesa/program/prog_instruction.c
index f9ebe4e8f..21ef35337 100644
--- a/mesalib/src/mesa/program/prog_instruction.c
+++ b/mesalib/src/mesa/program/prog_instruction.c
@@ -55,7 +55,7 @@ _mesa_init_instructions(struct prog_instruction *inst, GLuint count)
inst[i].DstReg.CondMask = COND_TR;
inst[i].DstReg.CondSwizzle = SWIZZLE_NOOP;
- inst[i].SaturateMode = SATURATE_OFF;
+ inst[i].Saturate = GL_FALSE;
inst[i].Precision = FLOAT32;
}
}
@@ -114,7 +114,7 @@ _mesa_free_instructions(struct prog_instruction *inst, GLuint count)
*/
struct instruction_info
{
- gl_inst_opcode Opcode;
+ enum prog_opcode Opcode;
const char *Name;
GLuint NumSrcRegs;
GLuint NumDstRegs;
@@ -198,7 +198,7 @@ static const struct instruction_info InstInfo[MAX_OPCODE] = {
* Return the number of src registers for the given instruction/opcode.
*/
GLuint
-_mesa_num_inst_src_regs(gl_inst_opcode opcode)
+_mesa_num_inst_src_regs(enum prog_opcode opcode)
{
assert(opcode < MAX_OPCODE);
assert(opcode == InstInfo[opcode].Opcode);
@@ -211,7 +211,7 @@ _mesa_num_inst_src_regs(gl_inst_opcode opcode)
* Return the number of dst registers for the given instruction/opcode.
*/
GLuint
-_mesa_num_inst_dst_regs(gl_inst_opcode opcode)
+_mesa_num_inst_dst_regs(enum prog_opcode opcode)
{
assert(opcode < MAX_OPCODE);
assert(opcode == InstInfo[opcode].Opcode);
@@ -221,7 +221,7 @@ _mesa_num_inst_dst_regs(gl_inst_opcode opcode)
GLboolean
-_mesa_is_tex_instruction(gl_inst_opcode opcode)
+_mesa_is_tex_instruction(enum prog_opcode opcode)
{
return (opcode == OPCODE_TEX ||
opcode == OPCODE_TXB ||
@@ -285,7 +285,7 @@ _mesa_check_soa_dependencies(const struct prog_instruction *inst)
* Return string name for given program opcode.
*/
const char *
-_mesa_opcode_string(gl_inst_opcode opcode)
+_mesa_opcode_string(enum prog_opcode opcode)
{
if (opcode < MAX_OPCODE)
return InstInfo[opcode].Name;
diff --git a/mesalib/src/mesa/program/prog_instruction.h b/mesalib/src/mesa/program/prog_instruction.h
index 96da198f8..d56f96cfa 100644
--- a/mesalib/src/mesa/program/prog_instruction.h
+++ b/mesalib/src/mesa/program/prog_instruction.h
@@ -118,15 +118,6 @@
/**
- * Saturation modes when storing values.
- */
-/*@{*/
-#define SATURATE_OFF 0
-#define SATURATE_ZERO_ONE 1
-/*@}*/
-
-
-/**
* Per-component negation masks
*/
/*@{*/
@@ -143,7 +134,7 @@
/**
* Program instruction opcodes for vertex, fragment and geometry programs.
*/
-typedef enum prog_opcode {
+enum prog_opcode {
/* ARB_vp ARB_fp NV_vp NV_fp GLSL */
/*------------------------------------------*/
OPCODE_NOP = 0, /* X */
@@ -213,7 +204,7 @@ typedef enum prog_opcode {
OPCODE_TRUNC, /* X */
OPCODE_XPD, /* X X */
MAX_OPCODE
-} gl_inst_opcode;
+};
/**
@@ -300,7 +291,7 @@ struct prog_dst_register
*/
struct prog_instruction
{
- gl_inst_opcode Opcode;
+ enum prog_opcode Opcode;
struct prog_src_register SrcReg[3];
struct prog_dst_register DstReg;
@@ -327,15 +318,12 @@ struct prog_instruction
GLuint CondDst:1;
/**
- * Saturate each value of the vectored result to the range [0,1] or the
- * range [-1,1]. \c SSAT mode (i.e., saturation to the range [-1,1]) is
- * only available in NV_fragment_program2 mode.
- * Value is one of the SATURATE_* tokens.
+ * Saturate each value of the vectored result to the range [0,1].
*
* \since
* NV_fragment_program_option, NV_vertex_program3.
*/
- GLuint SaturateMode:2;
+ GLuint Saturate:1;
/**
* Per-instruction selectable precision: FLOAT32, FLOAT16, FIXED12.
@@ -368,9 +356,6 @@ struct prog_instruction
*/
GLint BranchTarget;
- /** for driver use (try to remove someday) */
- GLint Aux;
-
/** for debugging purposes */
const char *Comment;
};
@@ -394,19 +379,19 @@ extern void
_mesa_free_instructions(struct prog_instruction *inst, GLuint count);
extern GLuint
-_mesa_num_inst_src_regs(gl_inst_opcode opcode);
+_mesa_num_inst_src_regs(enum prog_opcode opcode);
extern GLuint
-_mesa_num_inst_dst_regs(gl_inst_opcode opcode);
+_mesa_num_inst_dst_regs(enum prog_opcode opcode);
extern GLboolean
-_mesa_is_tex_instruction(gl_inst_opcode opcode);
+_mesa_is_tex_instruction(enum prog_opcode opcode);
extern GLboolean
_mesa_check_soa_dependencies(const struct prog_instruction *inst);
extern const char *
-_mesa_opcode_string(gl_inst_opcode opcode);
+_mesa_opcode_string(enum prog_opcode opcode);
#ifdef __cplusplus
diff --git a/mesalib/src/mesa/program/prog_optimize.c b/mesalib/src/mesa/program/prog_optimize.c
index 6d4485acb..f9e9035fc 100644
--- a/mesalib/src/mesa/program/prog_optimize.c
+++ b/mesalib/src/mesa/program/prog_optimize.c
@@ -478,7 +478,7 @@ can_upward_mov_be_modifed(const struct prog_instruction *mov)
return
can_downward_mov_be_modifed(mov) &&
mov->DstReg.File == PROGRAM_TEMPORARY &&
- mov->SaturateMode == SATURATE_OFF;
+ !mov->Saturate;
}
@@ -653,7 +653,7 @@ _mesa_merge_mov_into_inst(struct prog_instruction *inst,
if (mask != (inst->DstReg.WriteMask & mask))
return GL_FALSE;
- inst->SaturateMode |= mov->SaturateMode;
+ inst->Saturate |= mov->Saturate;
/* Depending on the instruction, we may need to recompute the swizzles.
* Also, some other instructions (like TEX) are not linear. We will only
diff --git a/mesalib/src/mesa/program/prog_print.c b/mesalib/src/mesa/program/prog_print.c
index d588d07ff..e4faa63c0 100644
--- a/mesalib/src/mesa/program/prog_print.c
+++ b/mesalib/src/mesa/program/prog_print.c
@@ -600,7 +600,7 @@ _mesa_fprint_alu_instruction(FILE *f,
fprintf(f, ".C");
/* frag prog only */
- if (inst->SaturateMode == SATURATE_ZERO_ONE)
+ if (inst->Saturate)
fprintf(f, "_SAT");
fprintf(f, " ");
@@ -658,7 +658,7 @@ _mesa_fprint_instruction_opt(FILE *f,
switch (inst->Opcode) {
case OPCODE_SWZ:
fprintf(f, "SWZ");
- if (inst->SaturateMode == SATURATE_ZERO_ONE)
+ if (inst->Saturate)
fprintf(f, "_SAT");
fprintf(f, " ");
fprint_dst_reg(f, &inst->DstReg, mode, prog);
@@ -675,7 +675,7 @@ _mesa_fprint_instruction_opt(FILE *f,
case OPCODE_TXB:
case OPCODE_TXD:
fprintf(f, "%s", _mesa_opcode_string(inst->Opcode));
- if (inst->SaturateMode == SATURATE_ZERO_ONE)
+ if (inst->Saturate)
fprintf(f, "_SAT");
fprintf(f, " ");
fprint_dst_reg(f, &inst->DstReg, mode, prog);
@@ -864,7 +864,7 @@ _mesa_fprint_program_opt(FILE *f,
else
fprintf(f, "# Fragment Program/Shader %u\n", prog->Id);
break;
- case MESA_GEOMETRY_PROGRAM:
+ case GL_GEOMETRY_PROGRAM_NV:
fprintf(f, "# Geometry Shader\n");
}
diff --git a/mesalib/src/mesa/program/prog_to_nir.c b/mesalib/src/mesa/program/prog_to_nir.c
index 6c5fa51ec..d54f93424 100644
--- a/mesalib/src/mesa/program/prog_to_nir.c
+++ b/mesalib/src/mesa/program/prog_to_nir.c
@@ -47,6 +47,7 @@ struct ptn_compile {
nir_builder build;
bool error;
+ nir_variable *parameters;
nir_variable *input_vars[VARYING_SLOT_MAX];
nir_variable *output_vars[VARYING_SLOT_MAX];
nir_register **output_regs;
@@ -112,21 +113,6 @@ ptn_get_dest(struct ptn_compile *c, const struct prog_dst_register *prog_dst)
return dest;
}
-/**
- * Multiply the contents of the ADDR register by 4 to convert from the number
- * of vec4s to the number of floating point components.
- */
-static nir_ssa_def *
-ptn_addr_reg_value(struct ptn_compile *c)
-{
- nir_builder *b = &c->build;
- nir_alu_src src;
- memset(&src, 0, sizeof(src));
- src.src = nir_src_for_reg(c->addr_reg);
-
- return nir_imul(b, nir_fmov_alu(b, src, 1), nir_imm_int(b, 4));
-}
-
static nir_ssa_def *
ptn_get_src(struct ptn_compile *c, const struct prog_src_register *prog_src)
{
@@ -180,27 +166,38 @@ ptn_get_src(struct ptn_compile *c, const struct prog_src_register *prog_src)
}
/* FALLTHROUGH */
case PROGRAM_STATE_VAR: {
- nir_intrinsic_op load_op =
- prog_src->RelAddr ? nir_intrinsic_load_uniform_indirect :
- nir_intrinsic_load_uniform;
- nir_intrinsic_instr *load = nir_intrinsic_instr_create(b->shader, load_op);
+ nir_intrinsic_instr *load =
+ nir_intrinsic_instr_create(b->shader, nir_intrinsic_load_var);
nir_ssa_dest_init(&load->instr, &load->dest, 4, NULL);
load->num_components = 4;
- /* Multiply src->Index by 4 to scale from # of vec4s to components. */
- load->const_index[0] = 4 * prog_src->Index;
- load->const_index[1] = 1;
+ load->variables[0] = nir_deref_var_create(load, c->parameters);
+ nir_deref_array *deref_arr =
+ nir_deref_array_create(load->variables[0]);
+ deref_arr->deref.type = glsl_vec4_type();
+ load->variables[0]->deref.child = &deref_arr->deref;
if (prog_src->RelAddr) {
- nir_ssa_def *reladdr = ptn_addr_reg_value(c);
+ deref_arr->deref_array_type = nir_deref_array_type_indirect;
+
+ nir_alu_src addr_src = { NIR_SRC_INIT };
+ addr_src.src = nir_src_for_reg(c->addr_reg);
+ nir_ssa_def *reladdr = nir_imov_alu(b, addr_src, 1);
+
if (prog_src->Index < 0) {
/* This is a negative offset which should be added to the address
* register's value.
*/
- reladdr = nir_iadd(b, reladdr, nir_imm_int(b, load->const_index[0]));
- load->const_index[0] = 0;
+ reladdr = nir_iadd(b, reladdr, nir_imm_int(b, prog_src->Index));
+
+ deref_arr->base_offset = 0;
+ } else {
+ deref_arr->base_offset = prog_src->Index;
}
- load->src[0] = nir_src_for_ssa(reladdr);
+ deref_arr->indirect = nir_src_for_ssa(reladdr);
+ } else {
+ deref_arr->deref_array_type = nir_deref_array_type_direct;
+ deref_arr->base_offset = prog_src->Index;
}
nir_instr_insert_after_cf_list(b->cf_node_list, &load->instr);
@@ -700,7 +697,7 @@ static const nir_op op_trans[MAX_OPCODE] = {
[OPCODE_ADD] = nir_op_fadd,
[OPCODE_ARL] = 0,
[OPCODE_CMP] = 0,
- [OPCODE_COS] = nir_op_fcos,
+ [OPCODE_COS] = 0,
[OPCODE_DDX] = nir_op_fddx,
[OPCODE_DDY] = nir_op_fddy,
[OPCODE_DP2] = 0,
@@ -709,11 +706,11 @@ static const nir_op op_trans[MAX_OPCODE] = {
[OPCODE_DPH] = 0,
[OPCODE_DST] = 0,
[OPCODE_END] = 0,
- [OPCODE_EX2] = nir_op_fexp2,
+ [OPCODE_EX2] = 0,
[OPCODE_EXP] = 0,
[OPCODE_FLR] = nir_op_ffloor,
[OPCODE_FRC] = nir_op_ffract,
- [OPCODE_LG2] = nir_op_flog2,
+ [OPCODE_LG2] = 0,
[OPCODE_LIT] = 0,
[OPCODE_LOG] = 0,
[OPCODE_LRP] = 0,
@@ -722,15 +719,15 @@ static const nir_op op_trans[MAX_OPCODE] = {
[OPCODE_MIN] = nir_op_fmin,
[OPCODE_MOV] = nir_op_fmov,
[OPCODE_MUL] = nir_op_fmul,
- [OPCODE_POW] = nir_op_fpow,
- [OPCODE_RCP] = nir_op_frcp,
+ [OPCODE_POW] = 0,
+ [OPCODE_RCP] = 0,
- [OPCODE_RSQ] = nir_op_frsq,
+ [OPCODE_RSQ] = 0,
[OPCODE_SCS] = 0,
[OPCODE_SEQ] = 0,
[OPCODE_SGE] = 0,
[OPCODE_SGT] = 0,
- [OPCODE_SIN] = nir_op_fsin,
+ [OPCODE_SIN] = 0,
[OPCODE_SLE] = 0,
[OPCODE_SLT] = 0,
[OPCODE_SNE] = 0,
@@ -767,7 +764,8 @@ ptn_emit_instruction(struct ptn_compile *c, struct prog_instruction *prog_inst)
switch (op) {
case OPCODE_RSQ:
- ptn_move_dest(b, dest, nir_frsq(b, ptn_channel(b, src[0], X)));
+ ptn_move_dest(b, dest,
+ nir_frsq(b, nir_fabs(b, ptn_channel(b, src[0], X))));
break;
case OPCODE_RCP:
@@ -894,7 +892,7 @@ ptn_emit_instruction(struct ptn_compile *c, struct prog_instruction *prog_inst)
break;
default:
- if (op_trans[op] != 0 || op == OPCODE_MOV) {
+ if (op_trans[op] != 0) {
ptn_alu(b, op_trans[op], dest, src);
} else {
fprintf(stderr, "unknown opcode: %s\n", _mesa_opcode_string(op));
@@ -903,8 +901,8 @@ ptn_emit_instruction(struct ptn_compile *c, struct prog_instruction *prog_inst)
break;
}
- if (prog_inst->SaturateMode) {
- assert(prog_inst->SaturateMode == SATURATE_ZERO_ONE);
+ if (prog_inst->Saturate) {
+ assert(prog_inst->Saturate);
assert(!dest.dest.is_ssa);
ptn_move_dest(b, dest, nir_fsat(b, ptn_src_for_dest(c, &dest)));
}
@@ -926,10 +924,23 @@ ptn_add_output_stores(struct ptn_compile *c)
foreach_list_typed(nir_variable, var, node, &b->shader->outputs) {
nir_intrinsic_instr *store =
nir_intrinsic_instr_create(b->shader, nir_intrinsic_store_var);
- store->num_components = 4;
+ store->num_components = glsl_get_vector_elements(var->type);
store->variables[0] =
nir_deref_var_create(store, c->output_vars[var->data.location]);
- store->src[0].reg.reg = c->output_regs[var->data.location];
+
+ if (c->prog->Target == GL_FRAGMENT_PROGRAM_ARB &&
+ var->data.location == FRAG_RESULT_DEPTH) {
+ /* result.depth has this strange convention of being the .z component of
+ * a vec4 with undefined .xyw components. We resolve it to a scalar, to
+ * match GLSL's gl_FragDepth and the expectations of most backends.
+ */
+ nir_alu_src alu_src = { NIR_SRC_INIT };
+ alu_src.src = nir_src_for_reg(c->output_regs[FRAG_RESULT_DEPTH]);
+ alu_src.swizzle[0] = SWIZZLE_Z;
+ store->src[0] = nir_src_for_ssa(nir_fmov_alu(b, alu_src, 1));
+ } else {
+ store->src[0].reg.reg = c->output_regs[var->data.location];
+ }
nir_instr_insert_after_cf_list(c->build.cf_node_list, &store->instr);
}
}
@@ -1022,7 +1033,10 @@ setup_registers_and_variables(struct ptn_compile *c)
reg->num_components = 4;
nir_variable *var = rzalloc(shader, nir_variable);
- var->type = glsl_vec4_type();
+ if (c->prog->Target == GL_FRAGMENT_PROGRAM_ARB && i == FRAG_RESULT_DEPTH)
+ var->type = glsl_float_type();
+ else
+ var->type = glsl_vec4_type();
var->data.mode = nir_var_shader_out;
var->name = ralloc_asprintf(var, "out_%d", i);
@@ -1057,13 +1071,11 @@ setup_registers_and_variables(struct ptn_compile *c)
}
reg->num_components = 1;
c->addr_reg = reg;
-
- /* Set the number of uniforms */
- shader->num_uniforms = 4 * c->prog->Parameters->NumParameters;
}
struct nir_shader *
-prog_to_nir(const struct gl_program *prog, const nir_shader_compiler_options *options)
+prog_to_nir(const struct gl_program *prog,
+ const nir_shader_compiler_options *options)
{
struct ptn_compile *c;
struct nir_shader *s;
@@ -1076,6 +1088,14 @@ prog_to_nir(const struct gl_program *prog, const nir_shader_compiler_options *op
goto fail;
c->prog = prog;
+ c->parameters = rzalloc(s, nir_variable);
+ c->parameters->type = glsl_array_type(glsl_vec4_type(),
+ prog->Parameters->NumParameters);
+ c->parameters->name = "parameters";
+ c->parameters->data.read_only = true;
+ c->parameters->data.mode = nir_var_uniform;
+ exec_list_push_tail(&s->uniforms, &c->parameters->node);
+
nir_function *func = nir_function_create(s, "main");
nir_function_overload *overload = nir_function_overload_create(func);
nir_function_impl *impl = nir_function_impl_create(overload);
diff --git a/mesalib/src/mesa/program/program.c b/mesalib/src/mesa/program/program.c
index fb61f4d36..c13e61b16 100644
--- a/mesalib/src/mesa/program/program.c
+++ b/mesalib/src/mesa/program/program.c
@@ -97,13 +97,6 @@ _mesa_init_program(struct gl_context *ctx)
assert(ctx->FragmentProgram.Current);
ctx->FragmentProgram.Cache = _mesa_new_program_cache();
- ctx->GeometryProgram.Enabled = GL_FALSE;
- /* right now by default we don't have a geometry program */
- _mesa_reference_geomprog(ctx, &ctx->GeometryProgram.Current,
- NULL);
-
- _mesa_reference_compprog(ctx, &ctx->ComputeProgram.Current, NULL);
-
/* XXX probably move this stuff */
ctx->ATIFragmentShader.Enabled = GL_FALSE;
ctx->ATIFragmentShader.Current = ctx->Shared->DefaultFragmentShader;
@@ -122,8 +115,6 @@ _mesa_free_program_data(struct gl_context *ctx)
_mesa_delete_program_cache(ctx, ctx->VertexProgram.Cache);
_mesa_reference_fragprog(ctx, &ctx->FragmentProgram.Current, NULL);
_mesa_delete_shader_cache(ctx, ctx->FragmentProgram.Cache);
- _mesa_reference_geomprog(ctx, &ctx->GeometryProgram.Current, NULL);
- _mesa_reference_compprog(ctx, &ctx->ComputeProgram.Current, NULL);
/* XXX probably move this stuff */
if (ctx->ATIFragmentShader.Current) {
@@ -153,9 +144,6 @@ _mesa_update_default_objects_program(struct gl_context *ctx)
ctx->Shared->DefaultFragmentProgram);
assert(ctx->FragmentProgram.Current);
- _mesa_reference_geomprog(ctx, &ctx->GeometryProgram.Current,
- ctx->Shared->DefaultGeometryProgram);
-
/* XXX probably move this stuff */
if (ctx->ATIFragmentShader.Current) {
ctx->ATIFragmentShader.Current->RefCount--;
@@ -340,7 +328,7 @@ _mesa_new_program(struct gl_context *ctx, GLenum target, GLuint id)
CALLOC_STRUCT(gl_fragment_program),
target, id );
break;
- case MESA_GEOMETRY_PROGRAM:
+ case GL_GEOMETRY_PROGRAM_NV:
prog = _mesa_init_geometry_program(ctx,
CALLOC_STRUCT(gl_geometry_program),
target, id);
@@ -426,8 +414,8 @@ _mesa_reference_program_(struct gl_context *ctx,
else if ((*ptr)->Target == GL_FRAGMENT_PROGRAM_ARB)
assert(prog->Target == GL_FRAGMENT_PROGRAM_ARB ||
prog->Target == GL_FRAGMENT_PROGRAM_NV);
- else if ((*ptr)->Target == MESA_GEOMETRY_PROGRAM)
- assert(prog->Target == MESA_GEOMETRY_PROGRAM);
+ else if ((*ptr)->Target == GL_GEOMETRY_PROGRAM_NV)
+ assert(prog->Target == GL_GEOMETRY_PROGRAM_NV);
}
#endif
@@ -439,7 +427,7 @@ _mesa_reference_program_(struct gl_context *ctx,
printf("Program %p ID=%u Target=%s Refcount-- to %d\n",
*ptr, (*ptr)->Id,
((*ptr)->Target == GL_VERTEX_PROGRAM_ARB ? "VP" :
- ((*ptr)->Target == MESA_GEOMETRY_PROGRAM ? "GP" : "FP")),
+ ((*ptr)->Target == GL_GEOMETRY_PROGRAM_NV ? "GP" : "FP")),
(*ptr)->RefCount - 1);
#endif
assert((*ptr)->RefCount > 0);
@@ -464,7 +452,7 @@ _mesa_reference_program_(struct gl_context *ctx,
printf("Program %p ID=%u Target=%s Refcount++ to %d\n",
prog, prog->Id,
(prog->Target == GL_VERTEX_PROGRAM_ARB ? "VP" :
- (prog->Target == MESA_GEOMETRY_PROGRAM ? "GP" : "FP")),
+ (prog->Target == GL_GEOMETRY_PROGRAM_NV ? "GP" : "FP")),
prog->RefCount);
#endif
/*mtx_unlock(&prog->Mutex);*/
@@ -554,7 +542,7 @@ _mesa_clone_program(struct gl_context *ctx, const struct gl_program *prog)
fpc->PixelCenterInteger = fp->PixelCenterInteger;
}
break;
- case MESA_GEOMETRY_PROGRAM:
+ case GL_GEOMETRY_PROGRAM_NV:
{
const struct gl_geometry_program *gp = gl_geometry_program_const(prog);
struct gl_geometry_program *gpc = gl_geometry_program(clone);
diff --git a/mesalib/src/mesa/program/program_parse.y b/mesalib/src/mesa/program/program_parse.y
index 716b83d2d..635f5d09d 100644
--- a/mesalib/src/mesa/program/program_parse.y
+++ b/mesalib/src/mesa/program/program_parse.y
@@ -84,7 +84,7 @@ static void asm_instruction_set_operands(struct asm_instruction *inst,
const struct prog_dst_register *dst, const struct asm_src_register *src0,
const struct asm_src_register *src1, const struct asm_src_register *src2);
-static struct asm_instruction *asm_instruction_ctor(gl_inst_opcode op,
+static struct asm_instruction *asm_instruction_ctor(enum prog_opcode op,
const struct prog_dst_register *dst, const struct asm_src_register *src0,
const struct asm_src_register *src1, const struct asm_src_register *src2);
@@ -139,7 +139,7 @@ static struct asm_instruction *asm_instruction_copy_ctor(
gl_state_index state[STATE_LENGTH];
int negate;
struct asm_vector vector;
- gl_inst_opcode opcode;
+ enum prog_opcode opcode;
struct {
unsigned swz;
@@ -2275,7 +2275,7 @@ asm_instruction_set_operands(struct asm_instruction *inst,
struct asm_instruction *
-asm_instruction_ctor(gl_inst_opcode op,
+asm_instruction_ctor(enum prog_opcode op,
const struct prog_dst_register *dst,
const struct asm_src_register *src0,
const struct asm_src_register *src1,
@@ -2308,7 +2308,7 @@ asm_instruction_copy_ctor(const struct prog_instruction *base,
inst->Base.Opcode = base->Opcode;
inst->Base.CondUpdate = base->CondUpdate;
inst->Base.CondDst = base->CondDst;
- inst->Base.SaturateMode = base->SaturateMode;
+ inst->Base.Saturate = base->Saturate;
inst->Base.Precision = base->Precision;
asm_instruction_set_operands(inst, dst, src0, src1, src2);
diff --git a/mesalib/src/mesa/program/program_parse_extra.c b/mesalib/src/mesa/program/program_parse_extra.c
index a9e364045..32b54afc5 100644
--- a/mesalib/src/mesa/program/program_parse_extra.c
+++ b/mesalib/src/mesa/program/program_parse_extra.c
@@ -40,7 +40,7 @@ _mesa_parse_instruction_suffix(const struct asm_parser_state *state,
{
inst->CondUpdate = 0;
inst->CondDst = 0;
- inst->SaturateMode = SATURATE_OFF;
+ inst->Saturate = GL_FALSE;
inst->Precision = FLOAT32;
@@ -82,7 +82,7 @@ _mesa_parse_instruction_suffix(const struct asm_parser_state *state,
*/
if (state->mode == ARB_fragment) {
if (strcmp(suffix, "_SAT") == 0) {
- inst->SaturateMode = SATURATE_ZERO_ONE;
+ inst->Saturate = GL_TRUE;
suffix += 4;
}
}
diff --git a/mesalib/src/mesa/program/programopt.c b/mesalib/src/mesa/program/programopt.c
index e82c68a53..af78150d5 100644
--- a/mesalib/src/mesa/program/programopt.c
+++ b/mesalib/src/mesa/program/programopt.c
@@ -305,7 +305,7 @@ _mesa_append_fog_code(struct gl_context *ctx,
/* change the instruction to write to colorTemp w/ clamping */
inst->DstReg.File = PROGRAM_TEMPORARY;
inst->DstReg.Index = colorTemp;
- inst->SaturateMode = saturate;
+ inst->Saturate = saturate;
/* don't break (may be several writes to result.color) */
}
inst++;
@@ -331,7 +331,7 @@ _mesa_append_fog_code(struct gl_context *ctx,
inst->SrcReg[2].File = PROGRAM_STATE_VAR;
inst->SrcReg[2].Index = fogPRefOpt;
inst->SrcReg[2].Swizzle = SWIZZLE_YYYY;
- inst->SaturateMode = SATURATE_ZERO_ONE;
+ inst->Saturate = GL_TRUE;
inst++;
}
else {
@@ -374,7 +374,7 @@ _mesa_append_fog_code(struct gl_context *ctx,
inst->SrcReg[0].Index = fogFactorTemp;
inst->SrcReg[0].Negate = NEGATE_XYZW;
inst->SrcReg[0].Swizzle = SWIZZLE_XXXX;
- inst->SaturateMode = SATURATE_ZERO_ONE;
+ inst->Saturate = GL_TRUE;
inst++;
}
/* LRP result.color.xyz, fogFactorTemp.xxxx, colorTemp, fogColorRef; */
diff --git a/mesalib/src/mesa/state_tracker/st_atom_shader.c b/mesalib/src/mesa/state_tracker/st_atom_shader.c
index 629f54f25..ad8d2624f 100644
--- a/mesalib/src/mesa/state_tracker/st_atom_shader.c
+++ b/mesalib/src/mesa/state_tracker/st_atom_shader.c
@@ -189,7 +189,7 @@ update_gp( struct st_context *st )
}
stgp = st_geometry_program(st->ctx->GeometryProgram._Current);
- assert(stgp->Base.Base.Target == MESA_GEOMETRY_PROGRAM);
+ assert(stgp->Base.Base.Target == GL_GEOMETRY_PROGRAM_NV);
memset(&key, 0, sizeof(key));
key.st = st;
diff --git a/mesalib/src/mesa/state_tracker/st_cb_bitmap.c b/mesalib/src/mesa/state_tracker/st_cb_bitmap.c
index 2107ab167..c881e194f 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_bitmap.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_bitmap.c
@@ -452,6 +452,8 @@ draw_bitmap_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
cso_save_fragment_shader(cso);
cso_save_stream_outputs(cso);
cso_save_vertex_shader(cso);
+ cso_save_tessctrl_shader(cso);
+ cso_save_tesseval_shader(cso);
cso_save_geometry_shader(cso);
cso_save_vertex_elements(cso);
cso_save_aux_vertex_buffer_slot(cso);
@@ -466,7 +468,9 @@ draw_bitmap_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
/* vertex shader state: position + texcoord pass-through */
cso_set_vertex_shader_handle(cso, st->bitmap.vs);
- /* geometry shader state: disabled */
+ /* disable other shaders */
+ cso_set_tessctrl_shader_handle(cso, NULL);
+ cso_set_tesseval_shader_handle(cso, NULL);
cso_set_geometry_shader_handle(cso, NULL);
/* user samplers, plus our bitmap sampler */
@@ -536,6 +540,8 @@ draw_bitmap_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
cso_restore_viewport(cso);
cso_restore_fragment_shader(cso);
cso_restore_vertex_shader(cso);
+ cso_restore_tessctrl_shader(cso);
+ cso_restore_tesseval_shader(cso);
cso_restore_geometry_shader(cso);
cso_restore_vertex_elements(cso);
cso_restore_aux_vertex_buffer_slot(cso);
diff --git a/mesalib/src/mesa/state_tracker/st_cb_blit.c b/mesalib/src/mesa/state_tracker/st_cb_blit.c
index bbaedd108..6d9371852 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_blit.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_blit.c
@@ -36,6 +36,7 @@
#include "st_context.h"
#include "st_texture.h"
+#include "st_cb_bitmap.h"
#include "st_cb_blit.h"
#include "st_cb_fbo.h"
#include "st_atom.h"
@@ -93,6 +94,9 @@ st_BlitFramebuffer(struct gl_context *ctx,
st_validate_state(st);
+ /* Make sure bitmap rendering has landed in the framebuffers */
+ st_flush_bitmap_cache(st);
+
clip.srcX0 = srcX0;
clip.srcY0 = srcY0;
clip.srcX1 = srcX1;
diff --git a/mesalib/src/mesa/state_tracker/st_cb_clear.c b/mesalib/src/mesa/state_tracker/st_cb_clear.c
index f10e9063a..137fac8a9 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_clear.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_clear.c
@@ -265,6 +265,8 @@ clear_with_quad(struct gl_context *ctx, unsigned clear_buffers)
cso_save_fragment_shader(st->cso_context);
cso_save_stream_outputs(st->cso_context);
cso_save_vertex_shader(st->cso_context);
+ cso_save_tessctrl_shader(st->cso_context);
+ cso_save_tesseval_shader(st->cso_context);
cso_save_geometry_shader(st->cso_context);
cso_save_vertex_elements(st->cso_context);
cso_save_aux_vertex_buffer_slot(st->cso_context);
@@ -347,6 +349,8 @@ clear_with_quad(struct gl_context *ctx, unsigned clear_buffers)
}
set_fragment_shader(st);
+ cso_set_tessctrl_shader_handle(st->cso_context, NULL);
+ cso_set_tesseval_shader_handle(st->cso_context, NULL);
if (num_layers > 1)
set_vertex_shader_layered(st);
@@ -371,6 +375,8 @@ clear_with_quad(struct gl_context *ctx, unsigned clear_buffers)
cso_restore_viewport(st->cso_context);
cso_restore_fragment_shader(st->cso_context);
cso_restore_vertex_shader(st->cso_context);
+ cso_restore_tessctrl_shader(st->cso_context);
+ cso_restore_tesseval_shader(st->cso_context);
cso_restore_geometry_shader(st->cso_context);
cso_restore_vertex_elements(st->cso_context);
cso_restore_aux_vertex_buffer_slot(st->cso_context);
diff --git a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
index 3edf31bad..a6a98c83a 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -693,6 +693,8 @@ draw_textured_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
cso_save_fragment_shader(cso);
cso_save_stream_outputs(cso);
cso_save_vertex_shader(cso);
+ cso_save_tessctrl_shader(cso);
+ cso_save_tesseval_shader(cso);
cso_save_geometry_shader(cso);
cso_save_vertex_elements(cso);
cso_save_aux_vertex_buffer_slot(cso);
@@ -746,7 +748,9 @@ draw_textured_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
/* vertex shader state: position + texcoord pass-through */
cso_set_vertex_shader_handle(cso, driver_vp);
- /* geometry shader state: disabled */
+ /* disable other shaders */
+ cso_set_tessctrl_shader_handle(cso, NULL);
+ cso_set_tesseval_shader_handle(cso, NULL);
cso_set_geometry_shader_handle(cso, NULL);
/* texture sampling state: */
@@ -816,6 +820,8 @@ draw_textured_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
cso_restore_sampler_views(cso, PIPE_SHADER_FRAGMENT);
cso_restore_fragment_shader(cso);
cso_restore_vertex_shader(cso);
+ cso_restore_tessctrl_shader(cso);
+ cso_restore_tesseval_shader(cso);
cso_restore_geometry_shader(cso);
cso_restore_vertex_elements(cso);
cso_restore_aux_vertex_buffer_slot(cso);
diff --git a/mesalib/src/mesa/state_tracker/st_cb_drawtex.c b/mesalib/src/mesa/state_tracker/st_cb_drawtex.c
index 1420b96e5..2af4f6d4c 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_drawtex.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_drawtex.c
@@ -229,6 +229,8 @@ st_DrawTex(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z,
cso_save_viewport(cso);
cso_save_stream_outputs(cso);
cso_save_vertex_shader(cso);
+ cso_save_tessctrl_shader(cso);
+ cso_save_tesseval_shader(cso);
cso_save_geometry_shader(cso);
cso_save_vertex_elements(cso);
cso_save_aux_vertex_buffer_slot(cso);
@@ -238,6 +240,8 @@ st_DrawTex(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z,
semantic_names, semantic_indexes);
cso_set_vertex_shader_handle(cso, vs);
}
+ cso_set_tessctrl_shader_handle(cso, NULL);
+ cso_set_tesseval_shader_handle(cso, NULL);
cso_set_geometry_shader_handle(cso, NULL);
for (i = 0; i < numAttribs; i++) {
@@ -279,6 +283,8 @@ st_DrawTex(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z,
/* restore state */
cso_restore_viewport(cso);
cso_restore_vertex_shader(cso);
+ cso_restore_tessctrl_shader(cso);
+ cso_restore_tesseval_shader(cso);
cso_restore_geometry_shader(cso);
cso_restore_vertex_elements(cso);
cso_restore_aux_vertex_buffer_slot(cso);
diff --git a/mesalib/src/mesa/state_tracker/st_cb_program.c b/mesalib/src/mesa/state_tracker/st_cb_program.c
index c382d7d2c..6aa7d5796 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_program.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_program.c
@@ -65,7 +65,7 @@ st_bind_program(struct gl_context *ctx, GLenum target, struct gl_program *prog)
case GL_FRAGMENT_PROGRAM_ARB:
st->dirty.st |= ST_NEW_FRAGMENT_PROGRAM;
break;
- case MESA_GEOMETRY_PROGRAM:
+ case GL_GEOMETRY_PROGRAM_NV:
st->dirty.st |= ST_NEW_GEOMETRY_PROGRAM;
break;
}
@@ -105,7 +105,7 @@ st_new_program(struct gl_context *ctx, GLenum target, GLuint id)
return _mesa_init_fragment_program(ctx, &prog->Base, target, id);
}
- case MESA_GEOMETRY_PROGRAM: {
+ case GL_GEOMETRY_PROGRAM_NV: {
struct st_geometry_program *prog = ST_CALLOC_STRUCT(st_geometry_program);
return _mesa_init_geometry_program(ctx, &prog->Base, target, id);
}
@@ -135,7 +135,7 @@ st_delete_program(struct gl_context *ctx, struct gl_program *prog)
free_glsl_to_tgsi_visitor(stvp->glsl_to_tgsi);
}
break;
- case MESA_GEOMETRY_PROGRAM:
+ case GL_GEOMETRY_PROGRAM_NV:
{
struct st_geometry_program *stgp =
(struct st_geometry_program *) prog;
@@ -198,7 +198,7 @@ st_program_string_notify( struct gl_context *ctx,
if (st->fp == stfp)
st->dirty.st |= ST_NEW_FRAGMENT_PROGRAM;
}
- else if (target == MESA_GEOMETRY_PROGRAM) {
+ else if (target == GL_GEOMETRY_PROGRAM_NV) {
struct st_geometry_program *stgp = (struct st_geometry_program *) prog;
st_release_gp_variants(st, stgp);
diff --git a/mesalib/src/mesa/state_tracker/st_context.c b/mesalib/src/mesa/state_tracker/st_context.c
index 69e0f929d..ed9ed0f1b 100644
--- a/mesalib/src/mesa/state_tracker/st_context.c
+++ b/mesalib/src/mesa/state_tracker/st_context.c
@@ -376,12 +376,6 @@ void st_destroy_context( struct st_context *st )
}
pipe_surface_reference(&st->state.framebuffer.zsbuf, NULL);
- pipe->set_index_buffer(pipe, NULL);
-
- for (i = 0; i < PIPE_SHADER_TYPES; i++) {
- pipe->set_constant_buffer(pipe, i, 0, NULL);
- }
-
_mesa_delete_program_cache(st->ctx, st->pixel_xfer.cache);
_vbo_DestroyContext(st->ctx);
diff --git a/mesalib/src/mesa/state_tracker/st_draw.c b/mesalib/src/mesa/state_tracker/st_draw.c
index 488f6ead2..8b43582c1 100644
--- a/mesalib/src/mesa/state_tracker/st_draw.c
+++ b/mesalib/src/mesa/state_tracker/st_draw.c
@@ -141,7 +141,7 @@ check_uniforms(struct gl_context *ctx)
if (shProg[j] == NULL || !shProg[j]->LinkStatus)
continue;
- for (i = 0; i < shProg[j]->NumUserUniformStorage; i++) {
+ for (i = 0; i < shProg[j]->NumUniformStorage; i++) {
const struct gl_uniform_storage *u = &shProg[j]->UniformStorage[i];
if (!u->initialized) {
_mesa_warning(ctx,
diff --git a/mesalib/src/mesa/state_tracker/st_extensions.c b/mesalib/src/mesa/state_tracker/st_extensions.c
index 23a45883d..b1057f3ea 100644
--- a/mesalib/src/mesa/state_tracker/st_extensions.c
+++ b/mesalib/src/mesa/state_tracker/st_extensions.c
@@ -650,12 +650,6 @@ void st_init_extensions(struct pipe_screen *screen,
ARRAY_SIZE(vertex_mapping), PIPE_BUFFER,
PIPE_BIND_VERTEX_BUFFER);
- /* ARB_direct_state_access requires OpenGL 2.0. Assume that all drivers
- * that support NPOT textures are able to support GL 2.0.
- */
- if (extensions->ARB_texture_non_power_of_two)
- extensions->ARB_direct_state_access = GL_TRUE;
-
if (extensions->ARB_stencil_texturing)
extensions->ARB_texture_stencil8 = GL_TRUE;
diff --git a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index f0f2a77d0..03834b69a 100644
--- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -57,11 +57,6 @@
(1 << PROGRAM_CONSTANT) | \
(1 << PROGRAM_UNIFORM))
-/**
- * Maximum number of arrays
- */
-#define MAX_ARRAYS 256
-
#define MAX_GLSL_TEXTURE_OFFSET 4
class st_src_reg;
@@ -89,6 +84,7 @@ public:
this->reladdr2 = NULL;
this->has_index2 = false;
this->double_reg2 = false;
+ this->array_id = 0;
}
st_src_reg(gl_register_file file, int index, int type)
@@ -103,6 +99,7 @@ public:
this->reladdr2 = NULL;
this->has_index2 = false;
this->double_reg2 = false;
+ this->array_id = 0;
}
st_src_reg(gl_register_file file, int index, int type, int index2D)
@@ -117,6 +114,7 @@ public:
this->reladdr2 = NULL;
this->has_index2 = false;
this->double_reg2 = false;
+ this->array_id = 0;
}
st_src_reg()
@@ -131,6 +129,7 @@ public:
this->reladdr2 = NULL;
this->has_index2 = false;
this->double_reg2 = false;
+ this->array_id = 0;
}
explicit st_src_reg(st_dst_reg reg);
@@ -150,6 +149,7 @@ public:
* currently used for input mapping only.
*/
bool double_reg2;
+ unsigned array_id;
};
class st_dst_reg {
@@ -162,6 +162,7 @@ public:
this->cond_mask = COND_TR;
this->reladdr = NULL;
this->type = type;
+ this->array_id = 0;
}
st_dst_reg(gl_register_file file, int writemask, int type)
@@ -172,6 +173,7 @@ public:
this->cond_mask = COND_TR;
this->reladdr = NULL;
this->type = type;
+ this->array_id = 0;
}
st_dst_reg()
@@ -182,6 +184,7 @@ public:
this->writemask = 0;
this->cond_mask = COND_TR;
this->reladdr = NULL;
+ this->array_id = 0;
}
explicit st_dst_reg(st_src_reg reg);
@@ -193,6 +196,7 @@ public:
int type; /** GLSL_TYPE_* from GLSL IR (enum glsl_base_type) */
/** Register index should be offset by the integer in this reg. */
st_src_reg *reladdr;
+ unsigned array_id;
};
st_src_reg::st_src_reg(st_dst_reg reg)
@@ -207,6 +211,7 @@ st_src_reg::st_src_reg(st_dst_reg reg)
this->reladdr2 = NULL;
this->has_index2 = false;
this->double_reg2 = false;
+ this->array_id = reg.array_id;
}
st_dst_reg::st_dst_reg(st_src_reg reg)
@@ -217,6 +222,7 @@ st_dst_reg::st_dst_reg(st_src_reg reg)
this->writemask = WRITEMASK_XYZW;
this->cond_mask = COND_TR;
this->reladdr = reg.reladdr;
+ this->array_id = reg.array_id;
}
class glsl_to_tgsi_instruction : public exec_node {
@@ -244,8 +250,9 @@ public:
class variable_storage : public exec_node {
public:
- variable_storage(ir_variable *var, gl_register_file file, int index)
- : file(file), index(index), var(var)
+ variable_storage(ir_variable *var, gl_register_file file, int index,
+ unsigned array_id = 0)
+ : file(file), index(index), var(var), array_id(array_id)
{
/* empty */
}
@@ -253,6 +260,7 @@ public:
gl_register_file file;
int index;
ir_variable *var; /* variable that maps to this, if any */
+ unsigned array_id;
};
class immediate_storage : public exec_node {
@@ -302,6 +310,15 @@ public:
st_src_reg return_reg;
};
+static st_src_reg undef_src = st_src_reg(PROGRAM_UNDEFINED, 0, GLSL_TYPE_ERROR);
+static st_dst_reg undef_dst = st_dst_reg(PROGRAM_UNDEFINED, SWIZZLE_NOOP, GLSL_TYPE_ERROR);
+
+struct array_decl {
+ unsigned mesa_index;
+ unsigned array_id;
+ unsigned array_size;
+};
+
struct glsl_to_tgsi_visitor : public ir_visitor {
public:
glsl_to_tgsi_visitor();
@@ -317,9 +334,15 @@ public:
int next_temp;
- unsigned array_sizes[MAX_ARRAYS];
+ unsigned *array_sizes;
+ unsigned max_num_arrays;
unsigned next_array;
+ struct array_decl input_arrays[PIPE_MAX_SHADER_INPUTS];
+ unsigned num_input_arrays;
+ struct array_decl output_arrays[PIPE_MAX_SHADER_OUTPUTS];
+ unsigned num_output_arrays;
+
int num_address_regs;
int samplers_used;
bool indirect_addr_consts;
@@ -372,6 +395,7 @@ public:
virtual void visit(ir_if *);
virtual void visit(ir_emit_vertex *);
virtual void visit(ir_end_primitive *);
+ virtual void visit(ir_barrier *);
/*@}*/
st_src_reg result;
@@ -390,31 +414,19 @@ public:
/** List of glsl_to_tgsi_instruction */
exec_list instructions;
- glsl_to_tgsi_instruction *emit(ir_instruction *ir, unsigned op);
-
- glsl_to_tgsi_instruction *emit(ir_instruction *ir, unsigned op,
- st_dst_reg dst, st_src_reg src0);
+ glsl_to_tgsi_instruction *emit_asm(ir_instruction *ir, unsigned op,
+ st_dst_reg dst = undef_dst,
+ st_src_reg src0 = undef_src,
+ st_src_reg src1 = undef_src,
+ st_src_reg src2 = undef_src,
+ st_src_reg src3 = undef_src);
- glsl_to_tgsi_instruction *emit(ir_instruction *ir, unsigned op,
- st_dst_reg dst, st_dst_reg dst1,
- st_src_reg src0);
-
- glsl_to_tgsi_instruction *emit(ir_instruction *ir, unsigned op,
- st_dst_reg dst, st_src_reg src0, st_src_reg src1);
-
- glsl_to_tgsi_instruction *emit(ir_instruction *ir, unsigned op,
- st_dst_reg dst,
- st_src_reg src0, st_src_reg src1, st_src_reg src2);
-
- glsl_to_tgsi_instruction *emit(ir_instruction *ir, unsigned op,
- st_dst_reg dst,
- st_src_reg src0, st_src_reg src1,
- st_src_reg src2, st_src_reg src3);
-
- glsl_to_tgsi_instruction *emit(ir_instruction *ir, unsigned op,
- st_dst_reg dst, st_dst_reg dst1,
- st_src_reg src0, st_src_reg src1,
- st_src_reg src2, st_src_reg src3);
+ glsl_to_tgsi_instruction *emit_asm(ir_instruction *ir, unsigned op,
+ st_dst_reg dst, st_dst_reg dst1,
+ st_src_reg src0 = undef_src,
+ st_src_reg src1 = undef_src,
+ st_src_reg src2 = undef_src,
+ st_src_reg src3 = undef_src);
unsigned get_opcode(ir_instruction *ir, unsigned op,
st_dst_reg dst,
@@ -468,10 +480,6 @@ public:
void *mem_ctx;
};
-static st_src_reg undef_src = st_src_reg(PROGRAM_UNDEFINED, 0, GLSL_TYPE_ERROR);
-
-static st_dst_reg undef_dst = st_dst_reg(PROGRAM_UNDEFINED, SWIZZLE_NOOP, GLSL_TYPE_ERROR);
-
static st_dst_reg address_reg = st_dst_reg(PROGRAM_ADDRESS, WRITEMASK_X, GLSL_TYPE_FLOAT, 0);
static st_dst_reg address_reg2 = st_dst_reg(PROGRAM_ADDRESS, WRITEMASK_X, GLSL_TYPE_FLOAT, 1);
static st_dst_reg sampler_reladdr = st_dst_reg(PROGRAM_ADDRESS, WRITEMASK_X, GLSL_TYPE_FLOAT, 2);
@@ -526,10 +534,10 @@ num_inst_src_regs(unsigned opcode)
}
glsl_to_tgsi_instruction *
-glsl_to_tgsi_visitor::emit(ir_instruction *ir, unsigned op,
- st_dst_reg dst, st_dst_reg dst1,
- st_src_reg src0, st_src_reg src1,
- st_src_reg src2, st_src_reg src3)
+glsl_to_tgsi_visitor::emit_asm(ir_instruction *ir, unsigned op,
+ st_dst_reg dst, st_dst_reg dst1,
+ st_src_reg src0, st_src_reg src1,
+ st_src_reg src2, st_src_reg src3)
{
glsl_to_tgsi_instruction *inst = new(mem_ctx) glsl_to_tgsi_instruction();
int num_reladdr = 0, i, j;
@@ -716,48 +724,12 @@ glsl_to_tgsi_visitor::emit(ir_instruction *ir, unsigned op,
}
glsl_to_tgsi_instruction *
-glsl_to_tgsi_visitor::emit(ir_instruction *ir, unsigned op,
- st_dst_reg dst,
- st_src_reg src0, st_src_reg src1,
- st_src_reg src2, st_src_reg src3)
-{
- return emit(ir, op, dst, undef_dst, src0, src1, src2, src3);
-}
-
-glsl_to_tgsi_instruction *
-glsl_to_tgsi_visitor::emit(ir_instruction *ir, unsigned op,
- st_dst_reg dst, st_src_reg src0,
- st_src_reg src1, st_src_reg src2)
-{
- return emit(ir, op, dst, undef_dst, src0, src1, src2, undef_src);
-}
-
-glsl_to_tgsi_instruction *
-glsl_to_tgsi_visitor::emit(ir_instruction *ir, unsigned op,
- st_dst_reg dst, st_src_reg src0, st_src_reg src1)
-{
- return emit(ir, op, dst, undef_dst, src0, src1, undef_src, undef_src);
-}
-
-glsl_to_tgsi_instruction *
-glsl_to_tgsi_visitor::emit(ir_instruction *ir, unsigned op,
- st_dst_reg dst, st_src_reg src0)
-{
- assert(dst.writemask != 0);
- return emit(ir, op, dst, undef_dst, src0, undef_src, undef_src, undef_src);
-}
-
-glsl_to_tgsi_instruction *
-glsl_to_tgsi_visitor::emit(ir_instruction *ir, unsigned op,
- st_dst_reg dst, st_dst_reg dst1, st_src_reg src0)
-{
- return emit(ir, op, dst, dst1, src0, undef_src, undef_src, undef_src);
-}
-
-glsl_to_tgsi_instruction *
-glsl_to_tgsi_visitor::emit(ir_instruction *ir, unsigned op)
+glsl_to_tgsi_visitor::emit_asm(ir_instruction *ir, unsigned op,
+ st_dst_reg dst,
+ st_src_reg src0, st_src_reg src1,
+ st_src_reg src2, st_src_reg src3)
{
- return emit(ir, op, undef_dst, undef_dst, undef_src, undef_src, undef_src, undef_src);
+ return emit_asm(ir, op, dst, undef_dst, src0, src1, src2, src3);
}
/**
@@ -879,7 +851,7 @@ glsl_to_tgsi_visitor::emit_dp(ir_instruction *ir,
TGSI_OPCODE_DP2, TGSI_OPCODE_DP3, TGSI_OPCODE_DP4
};
- return emit(ir, dot_opcodes[elements - 2], dst, src0, src1);
+ return emit_asm(ir, dot_opcodes[elements - 2], dst, src0, src1);
}
/**
@@ -929,7 +901,7 @@ glsl_to_tgsi_visitor::emit_scalar(ir_instruction *ir, unsigned op,
src1_swiz, src1_swiz);
dst.writemask = this_mask;
- emit(ir, op, dst, src0, src1);
+ emit_asm(ir, op, dst, src0, src1);
done_mask |= this_mask;
}
}
@@ -958,7 +930,7 @@ glsl_to_tgsi_visitor::emit_arl(ir_instruction *ir,
if (dst.index >= this->num_address_regs)
this->num_address_regs = dst.index + 1;
- emit(NULL, op, dst, src0);
+ emit_asm(NULL, op, dst, src0);
}
int
@@ -1142,6 +1114,12 @@ glsl_to_tgsi_visitor::get_temp(const glsl_type *type)
if (!options->EmitNoIndirectTemp &&
(type->is_array() || type->is_matrix())) {
+ if (next_array >= max_num_arrays) {
+ max_num_arrays += 32;
+ array_sizes = (unsigned*)
+ realloc(array_sizes, sizeof(array_sizes[0]) * max_num_arrays);
+ }
+
src.file = PROGRAM_ARRAY;
src.index = next_array << 16 | 0x8000;
array_sizes[next_array] = type_size(type);
@@ -1242,7 +1220,7 @@ glsl_to_tgsi_visitor::visit(ir_variable *ir)
*/
st_src_reg src(PROGRAM_STATE_VAR, index, GLSL_TYPE_FLOAT);
src.swizzle = slots[i].swizzle;
- emit(ir, TGSI_OPCODE_MOV, dst, src);
+ emit_asm(ir, TGSI_OPCODE_MOV, dst, src);
/* even a float takes up a whole vec4 reg in a struct/array. */
dst.index++;
}
@@ -1261,11 +1239,11 @@ glsl_to_tgsi_visitor::visit(ir_variable *ir)
void
glsl_to_tgsi_visitor::visit(ir_loop *ir)
{
- emit(NULL, TGSI_OPCODE_BGNLOOP);
+ emit_asm(NULL, TGSI_OPCODE_BGNLOOP);
visit_exec_list(&ir->body_instructions, this);
- emit(NULL, TGSI_OPCODE_ENDLOOP);
+ emit_asm(NULL, TGSI_OPCODE_ENDLOOP);
}
void
@@ -1273,10 +1251,10 @@ glsl_to_tgsi_visitor::visit(ir_loop_jump *ir)
{
switch (ir->mode) {
case ir_loop_jump::jump_break:
- emit(NULL, TGSI_OPCODE_BRK);
+ emit_asm(NULL, TGSI_OPCODE_BRK);
break;
case ir_loop_jump::jump_continue:
- emit(NULL, TGSI_OPCODE_CONT);
+ emit_asm(NULL, TGSI_OPCODE_CONT);
break;
}
}
@@ -1330,7 +1308,7 @@ glsl_to_tgsi_visitor::try_emit_mad(ir_expression *ir, int mul_operand)
this->result = get_temp(ir->type);
result_dst = st_dst_reg(this->result);
result_dst.writemask = (1 << ir->type->vector_elements) - 1;
- emit(ir, TGSI_OPCODE_MAD, result_dst, a, b, c);
+ emit_asm(ir, TGSI_OPCODE_MAD, result_dst, a, b, c);
return true;
}
@@ -1370,7 +1348,7 @@ glsl_to_tgsi_visitor::try_emit_mad_for_and_not(ir_expression *ir, int try_operan
b.negate = ~b.negate;
this->result = get_temp(ir->type);
- emit(ir, TGSI_OPCODE_MAD, st_dst_reg(this->result), a, b, a);
+ emit_asm(ir, TGSI_OPCODE_MAD, st_dst_reg(this->result), a, b, a);
return true;
}
@@ -1388,7 +1366,7 @@ glsl_to_tgsi_visitor::reladdr_to_temp(ir_instruction *ir,
if (*num_reladdr != 1) {
st_src_reg temp = get_temp(glsl_type::vec4_type);
- emit(ir, TGSI_OPCODE_MOV, st_dst_reg(temp), *reg);
+ emit_asm(ir, TGSI_OPCODE_MOV, st_dst_reg(temp), *reg);
*reg = temp;
}
@@ -1464,7 +1442,7 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
switch (ir->operation) {
case ir_unop_logic_not:
if (result_dst.type != GLSL_TYPE_FLOAT)
- emit(ir, TGSI_OPCODE_NOT, result_dst, op[0]);
+ emit_asm(ir, TGSI_OPCODE_NOT, result_dst, op[0]);
else {
/* Previously 'SEQ dst, src, 0.0' was used for this. However, many
* older GPUs implement SEQ using multiple instructions (i915 uses two
@@ -1472,24 +1450,24 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
* 0.0 and 1.0, 1-x also implements !x.
*/
op[0].negate = ~op[0].negate;
- emit(ir, TGSI_OPCODE_ADD, result_dst, op[0], st_src_reg_for_float(1.0));
+ emit_asm(ir, TGSI_OPCODE_ADD, result_dst, op[0], st_src_reg_for_float(1.0));
}
break;
case ir_unop_neg:
if (result_dst.type == GLSL_TYPE_INT || result_dst.type == GLSL_TYPE_UINT)
- emit(ir, TGSI_OPCODE_INEG, result_dst, op[0]);
+ emit_asm(ir, TGSI_OPCODE_INEG, result_dst, op[0]);
else if (result_dst.type == GLSL_TYPE_DOUBLE)
- emit(ir, TGSI_OPCODE_DNEG, result_dst, op[0]);
+ emit_asm(ir, TGSI_OPCODE_DNEG, result_dst, op[0]);
else {
op[0].negate = ~op[0].negate;
result_src = op[0];
}
break;
case ir_unop_abs:
- emit(ir, TGSI_OPCODE_ABS, result_dst, op[0]);
+ emit_asm(ir, TGSI_OPCODE_ABS, result_dst, op[0]);
break;
case ir_unop_sign:
- emit(ir, TGSI_OPCODE_SSG, result_dst, op[0]);
+ emit_asm(ir, TGSI_OPCODE_SSG, result_dst, op[0]);
break;
case ir_unop_rcp:
emit_scalar(ir, TGSI_OPCODE_RCP, result_dst, op[0]);
@@ -1513,17 +1491,17 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
break;
case ir_unop_saturate: {
glsl_to_tgsi_instruction *inst;
- inst = emit(ir, TGSI_OPCODE_MOV, result_dst, op[0]);
+ inst = emit_asm(ir, TGSI_OPCODE_MOV, result_dst, op[0]);
inst->saturate = true;
break;
}
case ir_unop_dFdx:
case ir_unop_dFdx_coarse:
- emit(ir, TGSI_OPCODE_DDX, result_dst, op[0]);
+ emit_asm(ir, TGSI_OPCODE_DDX, result_dst, op[0]);
break;
case ir_unop_dFdx_fine:
- emit(ir, TGSI_OPCODE_DDX_FINE, result_dst, op[0]);
+ emit_asm(ir, TGSI_OPCODE_DDX_FINE, result_dst, op[0]);
break;
case ir_unop_dFdy:
case ir_unop_dFdy_coarse:
@@ -1547,18 +1525,18 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
st_src_reg temp = get_temp(glsl_type::vec4_type);
- emit(ir, TGSI_OPCODE_MUL, st_dst_reg(temp), transform_y, op[0]);
- emit(ir, ir->operation == ir_unop_dFdy_fine ?
+ emit_asm(ir, TGSI_OPCODE_MUL, st_dst_reg(temp), transform_y, op[0]);
+ emit_asm(ir, ir->operation == ir_unop_dFdy_fine ?
TGSI_OPCODE_DDY_FINE : TGSI_OPCODE_DDY, result_dst, temp);
break;
}
case ir_unop_frexp_sig:
- emit(ir, TGSI_OPCODE_DFRACEXP, result_dst, undef_dst, op[0]);
+ emit_asm(ir, TGSI_OPCODE_DFRACEXP, result_dst, undef_dst, op[0]);
break;
case ir_unop_frexp_exp:
- emit(ir, TGSI_OPCODE_DFRACEXP, undef_dst, result_dst, op[0]);
+ emit_asm(ir, TGSI_OPCODE_DFRACEXP, undef_dst, result_dst, op[0]);
break;
case ir_unop_noise: {
@@ -1568,50 +1546,50 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
* place to do this is in the GL state tracker, not the poor
* driver.
*/
- emit(ir, TGSI_OPCODE_MOV, result_dst, st_src_reg_for_float(0.5));
+ emit_asm(ir, TGSI_OPCODE_MOV, result_dst, st_src_reg_for_float(0.5));
break;
}
case ir_binop_add:
- emit(ir, TGSI_OPCODE_ADD, result_dst, op[0], op[1]);
+ emit_asm(ir, TGSI_OPCODE_ADD, result_dst, op[0], op[1]);
break;
case ir_binop_sub:
- emit(ir, TGSI_OPCODE_SUB, result_dst, op[0], op[1]);
+ emit_asm(ir, TGSI_OPCODE_SUB, result_dst, op[0], op[1]);
break;
case ir_binop_mul:
- emit(ir, TGSI_OPCODE_MUL, result_dst, op[0], op[1]);
+ emit_asm(ir, TGSI_OPCODE_MUL, result_dst, op[0], op[1]);
break;
case ir_binop_div:
if (result_dst.type == GLSL_TYPE_FLOAT || result_dst.type == GLSL_TYPE_DOUBLE)
assert(!"not reached: should be handled by ir_div_to_mul_rcp");
else
- emit(ir, TGSI_OPCODE_DIV, result_dst, op[0], op[1]);
+ emit_asm(ir, TGSI_OPCODE_DIV, result_dst, op[0], op[1]);
break;
case ir_binop_mod:
if (result_dst.type == GLSL_TYPE_FLOAT)
assert(!"ir_binop_mod should have been converted to b * fract(a/b)");
else
- emit(ir, TGSI_OPCODE_MOD, result_dst, op[0], op[1]);
+ emit_asm(ir, TGSI_OPCODE_MOD, result_dst, op[0], op[1]);
break;
case ir_binop_less:
- emit(ir, TGSI_OPCODE_SLT, result_dst, op[0], op[1]);
+ emit_asm(ir, TGSI_OPCODE_SLT, result_dst, op[0], op[1]);
break;
case ir_binop_greater:
- emit(ir, TGSI_OPCODE_SLT, result_dst, op[1], op[0]);
+ emit_asm(ir, TGSI_OPCODE_SLT, result_dst, op[1], op[0]);
break;
case ir_binop_lequal:
- emit(ir, TGSI_OPCODE_SGE, result_dst, op[1], op[0]);
+ emit_asm(ir, TGSI_OPCODE_SGE, result_dst, op[1], op[0]);
break;
case ir_binop_gequal:
- emit(ir, TGSI_OPCODE_SGE, result_dst, op[0], op[1]);
+ emit_asm(ir, TGSI_OPCODE_SGE, result_dst, op[0], op[1]);
break;
case ir_binop_equal:
- emit(ir, TGSI_OPCODE_SEQ, result_dst, op[0], op[1]);
+ emit_asm(ir, TGSI_OPCODE_SEQ, result_dst, op[0], op[1]);
break;
case ir_binop_nequal:
- emit(ir, TGSI_OPCODE_SNE, result_dst, op[0], op[1]);
+ emit_asm(ir, TGSI_OPCODE_SNE, result_dst, op[0], op[1]);
break;
case ir_binop_all_equal:
/* "==" operator producing a scalar boolean. */
@@ -1625,7 +1603,7 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
st_dst_reg temp_dst = st_dst_reg(temp);
st_src_reg temp1 = st_src_reg(temp), temp2 = st_src_reg(temp);
- emit(ir, TGSI_OPCODE_SEQ, st_dst_reg(temp), op[0], op[1]);
+ emit_asm(ir, TGSI_OPCODE_SEQ, st_dst_reg(temp), op[0], op[1]);
/* Emit 1-3 AND operations to combine the SEQ results. */
switch (ir->operands[0]->type->vector_elements) {
@@ -1635,24 +1613,24 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
temp_dst.writemask = WRITEMASK_Y;
temp1.swizzle = SWIZZLE_YYYY;
temp2.swizzle = SWIZZLE_ZZZZ;
- emit(ir, TGSI_OPCODE_AND, temp_dst, temp1, temp2);
+ emit_asm(ir, TGSI_OPCODE_AND, temp_dst, temp1, temp2);
break;
case 4:
temp_dst.writemask = WRITEMASK_X;
temp1.swizzle = SWIZZLE_XXXX;
temp2.swizzle = SWIZZLE_YYYY;
- emit(ir, TGSI_OPCODE_AND, temp_dst, temp1, temp2);
+ emit_asm(ir, TGSI_OPCODE_AND, temp_dst, temp1, temp2);
temp_dst.writemask = WRITEMASK_Y;
temp1.swizzle = SWIZZLE_ZZZZ;
temp2.swizzle = SWIZZLE_WWWW;
- emit(ir, TGSI_OPCODE_AND, temp_dst, temp1, temp2);
+ emit_asm(ir, TGSI_OPCODE_AND, temp_dst, temp1, temp2);
}
temp1.swizzle = SWIZZLE_XXXX;
temp2.swizzle = SWIZZLE_YYYY;
- emit(ir, TGSI_OPCODE_AND, result_dst, temp1, temp2);
+ emit_asm(ir, TGSI_OPCODE_AND, result_dst, temp1, temp2);
} else {
- emit(ir, TGSI_OPCODE_SNE, st_dst_reg(temp), op[0], op[1]);
+ emit_asm(ir, TGSI_OPCODE_SNE, st_dst_reg(temp), op[0], op[1]);
/* After the dot-product, the value will be an integer on the
* range [0,4]. Zero becomes 1.0, and positive values become zero.
@@ -1665,10 +1643,10 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
*/
st_src_reg sge_src = result_src;
sge_src.negate = ~sge_src.negate;
- emit(ir, TGSI_OPCODE_SGE, result_dst, sge_src, st_src_reg_for_float(0.0));
+ emit_asm(ir, TGSI_OPCODE_SGE, result_dst, sge_src, st_src_reg_for_float(0.0));
}
} else {
- emit(ir, TGSI_OPCODE_SEQ, result_dst, op[0], op[1]);
+ emit_asm(ir, TGSI_OPCODE_SEQ, result_dst, op[0], op[1]);
}
break;
case ir_binop_any_nequal:
@@ -1678,7 +1656,7 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
st_src_reg temp = get_temp(native_integers ?
glsl_type::uvec4_type :
glsl_type::vec4_type);
- emit(ir, TGSI_OPCODE_SNE, st_dst_reg(temp), op[0], op[1]);
+ emit_asm(ir, TGSI_OPCODE_SNE, st_dst_reg(temp), op[0], op[1]);
if (native_integers) {
st_dst_reg temp_dst = st_dst_reg(temp);
@@ -1692,22 +1670,22 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
temp_dst.writemask = WRITEMASK_Y;
temp1.swizzle = SWIZZLE_YYYY;
temp2.swizzle = SWIZZLE_ZZZZ;
- emit(ir, TGSI_OPCODE_OR, temp_dst, temp1, temp2);
+ emit_asm(ir, TGSI_OPCODE_OR, temp_dst, temp1, temp2);
break;
case 4:
temp_dst.writemask = WRITEMASK_X;
temp1.swizzle = SWIZZLE_XXXX;
temp2.swizzle = SWIZZLE_YYYY;
- emit(ir, TGSI_OPCODE_OR, temp_dst, temp1, temp2);
+ emit_asm(ir, TGSI_OPCODE_OR, temp_dst, temp1, temp2);
temp_dst.writemask = WRITEMASK_Y;
temp1.swizzle = SWIZZLE_ZZZZ;
temp2.swizzle = SWIZZLE_WWWW;
- emit(ir, TGSI_OPCODE_OR, temp_dst, temp1, temp2);
+ emit_asm(ir, TGSI_OPCODE_OR, temp_dst, temp1, temp2);
}
temp1.swizzle = SWIZZLE_XXXX;
temp2.swizzle = SWIZZLE_YYYY;
- emit(ir, TGSI_OPCODE_OR, result_dst, temp1, temp2);
+ emit_asm(ir, TGSI_OPCODE_OR, result_dst, temp1, temp2);
} else {
/* After the dot-product, the value will be an integer on the
* range [0,4]. Zero stays zero, and positive values become 1.0.
@@ -1726,11 +1704,11 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
*/
st_src_reg slt_src = result_src;
slt_src.negate = ~slt_src.negate;
- emit(ir, TGSI_OPCODE_SLT, result_dst, slt_src, st_src_reg_for_float(0.0));
+ emit_asm(ir, TGSI_OPCODE_SLT, result_dst, slt_src, st_src_reg_for_float(0.0));
}
}
} else {
- emit(ir, TGSI_OPCODE_SNE, result_dst, op[0], op[1]);
+ emit_asm(ir, TGSI_OPCODE_SNE, result_dst, op[0], op[1]);
}
break;
@@ -1763,7 +1741,7 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
GET_SWZ(op0_swizzle, 3),
GET_SWZ(op0_swizzle, 3),
GET_SWZ(op0_swizzle, 3));
- emit(ir, TGSI_OPCODE_OR, result_dst, accum, op[0]);
+ emit_asm(ir, TGSI_OPCODE_OR, result_dst, accum, op[0]);
accum = st_src_reg(result_dst);
accum.swizzle = dst_swizzle;
/* fallthrough */
@@ -1772,7 +1750,7 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
GET_SWZ(op0_swizzle, 2),
GET_SWZ(op0_swizzle, 2),
GET_SWZ(op0_swizzle, 2));
- emit(ir, TGSI_OPCODE_OR, result_dst, accum, op[0]);
+ emit_asm(ir, TGSI_OPCODE_OR, result_dst, accum, op[0]);
accum = st_src_reg(result_dst);
accum.swizzle = dst_swizzle;
/* fallthrough */
@@ -1781,7 +1759,7 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
GET_SWZ(op0_swizzle, 1),
GET_SWZ(op0_swizzle, 1),
GET_SWZ(op0_swizzle, 1));
- emit(ir, TGSI_OPCODE_OR, result_dst, accum, op[0]);
+ emit_asm(ir, TGSI_OPCODE_OR, result_dst, accum, op[0]);
break;
default:
assert(!"Unexpected vector size");
@@ -1807,11 +1785,11 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
*/
st_src_reg slt_src = result_src;
slt_src.negate = ~slt_src.negate;
- emit(ir, TGSI_OPCODE_SLT, result_dst, slt_src, st_src_reg_for_float(0.0));
+ emit_asm(ir, TGSI_OPCODE_SLT, result_dst, slt_src, st_src_reg_for_float(0.0));
}
else {
/* Use SNE 0 if integers are being used as boolean values. */
- emit(ir, TGSI_OPCODE_SNE, result_dst, result_src, st_src_reg_for_int(0));
+ emit_asm(ir, TGSI_OPCODE_SNE, result_dst, result_src, st_src_reg_for_int(0));
}
}
break;
@@ -1819,9 +1797,9 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
case ir_binop_logic_xor:
if (native_integers)
- emit(ir, TGSI_OPCODE_XOR, result_dst, op[0], op[1]);
+ emit_asm(ir, TGSI_OPCODE_XOR, result_dst, op[0], op[1]);
else
- emit(ir, TGSI_OPCODE_SNE, result_dst, op[0], op[1]);
+ emit_asm(ir, TGSI_OPCODE_SNE, result_dst, op[0], op[1]);
break;
case ir_binop_logic_or: {
@@ -1830,13 +1808,13 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
* instruction.
*/
assert(native_integers);
- emit(ir, TGSI_OPCODE_OR, result_dst, op[0], op[1]);
+ emit_asm(ir, TGSI_OPCODE_OR, result_dst, op[0], op[1]);
} else {
/* After the addition, the value will be an integer on the
* range [0,2]. Zero stays zero, and positive values become 1.0.
*/
glsl_to_tgsi_instruction *add =
- emit(ir, TGSI_OPCODE_ADD, result_dst, op[0], op[1]);
+ emit_asm(ir, TGSI_OPCODE_ADD, result_dst, op[0], op[1]);
if (this->prog->Target == GL_FRAGMENT_PROGRAM_ARB) {
/* The clamping to [0,1] can be done for free in the fragment
* shader with a saturate if floats are being used as boolean values.
@@ -1849,7 +1827,7 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
*/
st_src_reg slt_src = result_src;
slt_src.negate = ~slt_src.negate;
- emit(ir, TGSI_OPCODE_SLT, result_dst, slt_src, st_src_reg_for_float(0.0));
+ emit_asm(ir, TGSI_OPCODE_SLT, result_dst, slt_src, st_src_reg_for_float(0.0));
}
}
break;
@@ -1861,9 +1839,9 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
* actual AND opcode.
*/
if (native_integers)
- emit(ir, TGSI_OPCODE_AND, result_dst, op[0], op[1]);
+ emit_asm(ir, TGSI_OPCODE_AND, result_dst, op[0], op[1]);
else
- emit(ir, TGSI_OPCODE_MUL, result_dst, op[0], op[1]);
+ emit_asm(ir, TGSI_OPCODE_MUL, result_dst, op[0], op[1]);
break;
case ir_binop_dot:
@@ -1879,10 +1857,10 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
} else {
/* sqrt(x) = x * rsq(x). */
emit_scalar(ir, TGSI_OPCODE_RSQ, result_dst, op[0]);
- emit(ir, TGSI_OPCODE_MUL, result_dst, result_src, op[0]);
+ emit_asm(ir, TGSI_OPCODE_MUL, result_dst, result_src, op[0]);
/* For incoming channels <= 0, set the result to 0. */
op[0].negate = ~op[0].negate;
- emit(ir, TGSI_OPCODE_CMP, result_dst,
+ emit_asm(ir, TGSI_OPCODE_CMP, result_dst,
op[0], result_src, st_src_reg_for_float(0.0));
}
break;
@@ -1891,13 +1869,13 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
break;
case ir_unop_i2f:
if (native_integers) {
- emit(ir, TGSI_OPCODE_I2F, result_dst, op[0]);
+ emit_asm(ir, TGSI_OPCODE_I2F, result_dst, op[0]);
break;
}
/* fallthrough to next case otherwise */
case ir_unop_b2f:
if (native_integers) {
- emit(ir, TGSI_OPCODE_AND, result_dst, op[0], st_src_reg_for_float(1.0));
+ emit_asm(ir, TGSI_OPCODE_AND, result_dst, op[0], st_src_reg_for_float(1.0));
break;
}
/* fallthrough to next case otherwise */
@@ -1912,7 +1890,7 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
* GLSL requires that int(bool) return 1 for true and 0 for false.
* This conversion is done with AND, but it could be done with NEG.
*/
- emit(ir, TGSI_OPCODE_AND, result_dst, op[0], st_src_reg_for_int(1));
+ emit_asm(ir, TGSI_OPCODE_AND, result_dst, op[0], st_src_reg_for_int(1));
} else {
/* Booleans and integers are both stored as floats when native
* integers are disabled.
@@ -1922,15 +1900,15 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
break;
case ir_unop_f2i:
if (native_integers)
- emit(ir, TGSI_OPCODE_F2I, result_dst, op[0]);
+ emit_asm(ir, TGSI_OPCODE_F2I, result_dst, op[0]);
else
- emit(ir, TGSI_OPCODE_TRUNC, result_dst, op[0]);
+ emit_asm(ir, TGSI_OPCODE_TRUNC, result_dst, op[0]);
break;
case ir_unop_f2u:
if (native_integers)
- emit(ir, TGSI_OPCODE_F2U, result_dst, op[0]);
+ emit_asm(ir, TGSI_OPCODE_F2U, result_dst, op[0]);
else
- emit(ir, TGSI_OPCODE_TRUNC, result_dst, op[0]);
+ emit_asm(ir, TGSI_OPCODE_TRUNC, result_dst, op[0]);
break;
case ir_unop_bitcast_f2i:
result_src = op[0];
@@ -1946,38 +1924,38 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
result_src.type = GLSL_TYPE_FLOAT;
break;
case ir_unop_f2b:
- emit(ir, TGSI_OPCODE_SNE, result_dst, op[0], st_src_reg_for_float(0.0));
+ emit_asm(ir, TGSI_OPCODE_SNE, result_dst, op[0], st_src_reg_for_float(0.0));
break;
case ir_unop_d2b:
- emit(ir, TGSI_OPCODE_SNE, result_dst, op[0], st_src_reg_for_double(0.0));
+ emit_asm(ir, TGSI_OPCODE_SNE, result_dst, op[0], st_src_reg_for_double(0.0));
break;
case ir_unop_i2b:
if (native_integers)
- emit(ir, TGSI_OPCODE_USNE, result_dst, op[0], st_src_reg_for_int(0));
+ emit_asm(ir, TGSI_OPCODE_USNE, result_dst, op[0], st_src_reg_for_int(0));
else
- emit(ir, TGSI_OPCODE_SNE, result_dst, op[0], st_src_reg_for_float(0.0));
+ emit_asm(ir, TGSI_OPCODE_SNE, result_dst, op[0], st_src_reg_for_float(0.0));
break;
case ir_unop_trunc:
- emit(ir, TGSI_OPCODE_TRUNC, result_dst, op[0]);
+ emit_asm(ir, TGSI_OPCODE_TRUNC, result_dst, op[0]);
break;
case ir_unop_ceil:
- emit(ir, TGSI_OPCODE_CEIL, result_dst, op[0]);
+ emit_asm(ir, TGSI_OPCODE_CEIL, result_dst, op[0]);
break;
case ir_unop_floor:
- emit(ir, TGSI_OPCODE_FLR, result_dst, op[0]);
+ emit_asm(ir, TGSI_OPCODE_FLR, result_dst, op[0]);
break;
case ir_unop_round_even:
- emit(ir, TGSI_OPCODE_ROUND, result_dst, op[0]);
+ emit_asm(ir, TGSI_OPCODE_ROUND, result_dst, op[0]);
break;
case ir_unop_fract:
- emit(ir, TGSI_OPCODE_FRC, result_dst, op[0]);
+ emit_asm(ir, TGSI_OPCODE_FRC, result_dst, op[0]);
break;
case ir_binop_min:
- emit(ir, TGSI_OPCODE_MIN, result_dst, op[0], op[1]);
+ emit_asm(ir, TGSI_OPCODE_MIN, result_dst, op[0], op[1]);
break;
case ir_binop_max:
- emit(ir, TGSI_OPCODE_MAX, result_dst, op[0], op[1]);
+ emit_asm(ir, TGSI_OPCODE_MAX, result_dst, op[0], op[1]);
break;
case ir_binop_pow:
emit_scalar(ir, TGSI_OPCODE_POW, result_dst, op[0], op[1]);
@@ -1985,37 +1963,37 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
case ir_unop_bit_not:
if (native_integers) {
- emit(ir, TGSI_OPCODE_NOT, result_dst, op[0]);
+ emit_asm(ir, TGSI_OPCODE_NOT, result_dst, op[0]);
break;
}
case ir_unop_u2f:
if (native_integers) {
- emit(ir, TGSI_OPCODE_U2F, result_dst, op[0]);
+ emit_asm(ir, TGSI_OPCODE_U2F, result_dst, op[0]);
break;
}
case ir_binop_lshift:
if (native_integers) {
- emit(ir, TGSI_OPCODE_SHL, result_dst, op[0], op[1]);
+ emit_asm(ir, TGSI_OPCODE_SHL, result_dst, op[0], op[1]);
break;
}
case ir_binop_rshift:
if (native_integers) {
- emit(ir, TGSI_OPCODE_ISHR, result_dst, op[0], op[1]);
+ emit_asm(ir, TGSI_OPCODE_ISHR, result_dst, op[0], op[1]);
break;
}
case ir_binop_bit_and:
if (native_integers) {
- emit(ir, TGSI_OPCODE_AND, result_dst, op[0], op[1]);
+ emit_asm(ir, TGSI_OPCODE_AND, result_dst, op[0], op[1]);
break;
}
case ir_binop_bit_xor:
if (native_integers) {
- emit(ir, TGSI_OPCODE_XOR, result_dst, op[0], op[1]);
+ emit_asm(ir, TGSI_OPCODE_XOR, result_dst, op[0], op[1]);
break;
}
case ir_binop_bit_or:
if (native_integers) {
- emit(ir, TGSI_OPCODE_OR, result_dst, op[0], op[1]);
+ emit_asm(ir, TGSI_OPCODE_OR, result_dst, op[0], op[1]);
break;
}
@@ -2045,7 +2023,7 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
}
else {
/* Relative/variable index into constant buffer */
- emit(ir, TGSI_OPCODE_USHR, st_dst_reg(index_reg), op[1],
+ emit_asm(ir, TGSI_OPCODE_USHR, st_dst_reg(index_reg), op[1],
st_src_reg_for_int(4));
cbuf.reladdr = ralloc(mem_ctx, st_src_reg);
memcpy(cbuf.reladdr, &index_reg, sizeof(index_reg));
@@ -2078,88 +2056,88 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
const_offset % 16 / 4);
if (ir->type->base_type == GLSL_TYPE_BOOL) {
- emit(ir, TGSI_OPCODE_USNE, result_dst, cbuf, st_src_reg_for_int(0));
+ emit_asm(ir, TGSI_OPCODE_USNE, result_dst, cbuf, st_src_reg_for_int(0));
} else {
- emit(ir, TGSI_OPCODE_MOV, result_dst, cbuf);
+ emit_asm(ir, TGSI_OPCODE_MOV, result_dst, cbuf);
}
break;
}
case ir_triop_lrp:
/* note: we have to reorder the three args here */
- emit(ir, TGSI_OPCODE_LRP, result_dst, op[2], op[1], op[0]);
+ emit_asm(ir, TGSI_OPCODE_LRP, result_dst, op[2], op[1], op[0]);
break;
case ir_triop_csel:
if (this->ctx->Const.NativeIntegers)
- emit(ir, TGSI_OPCODE_UCMP, result_dst, op[0], op[1], op[2]);
+ emit_asm(ir, TGSI_OPCODE_UCMP, result_dst, op[0], op[1], op[2]);
else {
op[0].negate = ~op[0].negate;
- emit(ir, TGSI_OPCODE_CMP, result_dst, op[0], op[1], op[2]);
+ emit_asm(ir, TGSI_OPCODE_CMP, result_dst, op[0], op[1], op[2]);
}
break;
case ir_triop_bitfield_extract:
- emit(ir, TGSI_OPCODE_IBFE, result_dst, op[0], op[1], op[2]);
+ emit_asm(ir, TGSI_OPCODE_IBFE, result_dst, op[0], op[1], op[2]);
break;
case ir_quadop_bitfield_insert:
- emit(ir, TGSI_OPCODE_BFI, result_dst, op[0], op[1], op[2], op[3]);
+ emit_asm(ir, TGSI_OPCODE_BFI, result_dst, op[0], op[1], op[2], op[3]);
break;
case ir_unop_bitfield_reverse:
- emit(ir, TGSI_OPCODE_BREV, result_dst, op[0]);
+ emit_asm(ir, TGSI_OPCODE_BREV, result_dst, op[0]);
break;
case ir_unop_bit_count:
- emit(ir, TGSI_OPCODE_POPC, result_dst, op[0]);
+ emit_asm(ir, TGSI_OPCODE_POPC, result_dst, op[0]);
break;
case ir_unop_find_msb:
- emit(ir, TGSI_OPCODE_IMSB, result_dst, op[0]);
+ emit_asm(ir, TGSI_OPCODE_IMSB, result_dst, op[0]);
break;
case ir_unop_find_lsb:
- emit(ir, TGSI_OPCODE_LSB, result_dst, op[0]);
+ emit_asm(ir, TGSI_OPCODE_LSB, result_dst, op[0]);
break;
case ir_binop_imul_high:
- emit(ir, TGSI_OPCODE_IMUL_HI, result_dst, op[0], op[1]);
+ emit_asm(ir, TGSI_OPCODE_IMUL_HI, result_dst, op[0], op[1]);
break;
case ir_triop_fma:
/* In theory, MAD is incorrect here. */
if (have_fma)
- emit(ir, TGSI_OPCODE_FMA, result_dst, op[0], op[1], op[2]);
+ emit_asm(ir, TGSI_OPCODE_FMA, result_dst, op[0], op[1], op[2]);
else
- emit(ir, TGSI_OPCODE_MAD, result_dst, op[0], op[1], op[2]);
+ emit_asm(ir, TGSI_OPCODE_MAD, result_dst, op[0], op[1], op[2]);
break;
case ir_unop_interpolate_at_centroid:
- emit(ir, TGSI_OPCODE_INTERP_CENTROID, result_dst, op[0]);
+ emit_asm(ir, TGSI_OPCODE_INTERP_CENTROID, result_dst, op[0]);
break;
case ir_binop_interpolate_at_offset:
- emit(ir, TGSI_OPCODE_INTERP_OFFSET, result_dst, op[0], op[1]);
+ emit_asm(ir, TGSI_OPCODE_INTERP_OFFSET, result_dst, op[0], op[1]);
break;
case ir_binop_interpolate_at_sample:
- emit(ir, TGSI_OPCODE_INTERP_SAMPLE, result_dst, op[0], op[1]);
+ emit_asm(ir, TGSI_OPCODE_INTERP_SAMPLE, result_dst, op[0], op[1]);
break;
case ir_unop_d2f:
- emit(ir, TGSI_OPCODE_D2F, result_dst, op[0]);
+ emit_asm(ir, TGSI_OPCODE_D2F, result_dst, op[0]);
break;
case ir_unop_f2d:
- emit(ir, TGSI_OPCODE_F2D, result_dst, op[0]);
+ emit_asm(ir, TGSI_OPCODE_F2D, result_dst, op[0]);
break;
case ir_unop_d2i:
- emit(ir, TGSI_OPCODE_D2I, result_dst, op[0]);
+ emit_asm(ir, TGSI_OPCODE_D2I, result_dst, op[0]);
break;
case ir_unop_i2d:
- emit(ir, TGSI_OPCODE_I2D, result_dst, op[0]);
+ emit_asm(ir, TGSI_OPCODE_I2D, result_dst, op[0]);
break;
case ir_unop_d2u:
- emit(ir, TGSI_OPCODE_D2U, result_dst, op[0]);
+ emit_asm(ir, TGSI_OPCODE_D2U, result_dst, op[0]);
break;
case ir_unop_u2d:
- emit(ir, TGSI_OPCODE_U2D, result_dst, op[0]);
+ emit_asm(ir, TGSI_OPCODE_U2D, result_dst, op[0]);
break;
case ir_unop_unpack_double_2x32:
case ir_unop_pack_double_2x32:
- emit(ir, TGSI_OPCODE_MOV, result_dst, op[0]);
+ emit_asm(ir, TGSI_OPCODE_MOV, result_dst, op[0]);
break;
case ir_binop_ldexp:
if (ir->operands[0]->type->base_type == GLSL_TYPE_DOUBLE) {
- emit(ir, TGSI_OPCODE_DLDEXP, result_dst, op[0], op[1]);
+ emit_asm(ir, TGSI_OPCODE_DLDEXP, result_dst, op[0], op[1]);
} else {
assert(!"Invalid ldexp for non-double opcode in glsl_to_tgsi_visitor::visit()");
}
@@ -2243,11 +2221,38 @@ glsl_to_tgsi_visitor::visit(ir_swizzle *ir)
this->result = src;
}
+/* Test if the variable is an array. Note that geometry and
+ * tessellation shader inputs are outputs are always arrays (except
+ * for patch inputs), so only the array element type is considered.
+ */
+static bool
+is_inout_array(unsigned stage, ir_variable *var, bool *is_2d)
+{
+ const glsl_type *type = var->type;
+
+ if ((stage == MESA_SHADER_VERTEX && var->data.mode == ir_var_shader_in) ||
+ (stage == MESA_SHADER_FRAGMENT && var->data.mode == ir_var_shader_out))
+ return false;
+
+ *is_2d = false;
+
+ if (stage == MESA_SHADER_GEOMETRY && var->data.mode == ir_var_shader_in) {
+ if (!var->type->is_array())
+ return false; /* a system value probably */
+
+ type = var->type->fields.array;
+ *is_2d = true;
+ }
+
+ return type->is_array() || type->is_matrix();
+}
+
void
glsl_to_tgsi_visitor::visit(ir_dereference_variable *ir)
{
variable_storage *entry = find_variable_storage(ir->var);
ir_variable *var = ir->var;
+ bool is_2d;
if (!entry) {
switch (var->data.mode) {
@@ -2263,16 +2268,56 @@ glsl_to_tgsi_visitor::visit(ir_dereference_variable *ir)
* user-defined varyings.
*/
assert(var->data.location != -1);
- entry = new(mem_ctx) variable_storage(var,
- PROGRAM_INPUT,
- var->data.location);
+
+ if (is_inout_array(shader->Stage, var, &is_2d)) {
+ struct array_decl *decl = &input_arrays[num_input_arrays];
+
+ decl->mesa_index = var->data.location;
+ decl->array_id = num_input_arrays + 1;
+ if (is_2d)
+ decl->array_size = type_size(var->type->fields.array);
+ else
+ decl->array_size = type_size(var->type);
+ num_input_arrays++;
+
+ entry = new(mem_ctx) variable_storage(var,
+ PROGRAM_INPUT,
+ var->data.location,
+ decl->array_id);
+ }
+ else {
+ entry = new(mem_ctx) variable_storage(var,
+ PROGRAM_INPUT,
+ var->data.location);
+ }
+ this->variables.push_tail(entry);
break;
case ir_var_shader_out:
assert(var->data.location != -1);
- entry = new(mem_ctx) variable_storage(var,
- PROGRAM_OUTPUT,
- var->data.location
- + var->data.index);
+
+ if (is_inout_array(shader->Stage, var, &is_2d)) {
+ struct array_decl *decl = &output_arrays[num_output_arrays];
+
+ decl->mesa_index = var->data.location;
+ decl->array_id = num_output_arrays + 1;
+ if (is_2d)
+ decl->array_size = type_size(var->type->fields.array);
+ else
+ decl->array_size = type_size(var->type);
+ num_output_arrays++;
+
+ entry = new(mem_ctx) variable_storage(var,
+ PROGRAM_OUTPUT,
+ var->data.location,
+ decl->array_id);
+ }
+ else {
+ entry = new(mem_ctx) variable_storage(var,
+ PROGRAM_OUTPUT,
+ var->data.location
+ + var->data.index);
+ }
+ this->variables.push_tail(entry);
break;
case ir_var_system_value:
entry = new(mem_ctx) variable_storage(var,
@@ -2296,10 +2341,43 @@ glsl_to_tgsi_visitor::visit(ir_dereference_variable *ir)
}
this->result = st_src_reg(entry->file, entry->index, var->type);
+ this->result.array_id = entry->array_id;
if (!native_integers)
this->result.type = GLSL_TYPE_FLOAT;
}
+static void
+shrink_array_declarations(struct array_decl *arrays, unsigned count,
+ GLbitfield64 usage_mask)
+{
+ unsigned i, j;
+
+ /* Fix array declarations by removing unused array elements at both ends
+ * of the arrays. For example, mat4[3] where only mat[1] is used.
+ */
+ for (i = 0; i < count; i++) {
+ struct array_decl *decl = &arrays[i];
+
+ /* Shrink the beginning. */
+ for (j = 0; j < decl->array_size; j++) {
+ if (usage_mask & BITFIELD64_BIT(decl->mesa_index+j))
+ break;
+
+ decl->mesa_index++;
+ decl->array_size--;
+ j--;
+ }
+
+ /* Shrink the end. */
+ for (j = decl->array_size-1; j >= 0; j--) {
+ if (usage_mask & BITFIELD64_BIT(decl->mesa_index+j))
+ break;
+
+ decl->array_size--;
+ }
+ }
+}
+
void
glsl_to_tgsi_visitor::visit(ir_dereference_array *ir)
{
@@ -2341,7 +2419,7 @@ glsl_to_tgsi_visitor::visit(ir_dereference_array *ir)
index_reg = get_temp(native_integers ?
glsl_type::int_type : glsl_type::float_type);
- emit(ir, TGSI_OPCODE_MUL, st_dst_reg(index_reg),
+ emit_asm(ir, TGSI_OPCODE_MUL, st_dst_reg(index_reg),
this->result, st_src_reg_for_type(index_reg.type, element_size));
}
@@ -2352,7 +2430,7 @@ glsl_to_tgsi_visitor::visit(ir_dereference_array *ir)
st_src_reg accum_reg = get_temp(native_integers ?
glsl_type::int_type : glsl_type::float_type);
- emit(ir, TGSI_OPCODE_ADD, st_dst_reg(accum_reg),
+ emit_asm(ir, TGSI_OPCODE_ADD, st_dst_reg(accum_reg),
index_reg, *src.reladdr);
index_reg = accum_reg;
@@ -2589,16 +2667,16 @@ glsl_to_tgsi_visitor::emit_block_mov(ir_assignment *ir, const struct glsl_type *
l_src.swizzle = swizzle_for_size(type->vector_elements);
if (native_integers) {
- emit(ir, TGSI_OPCODE_UCMP, *l, *cond,
+ emit_asm(ir, TGSI_OPCODE_UCMP, *l, *cond,
cond_swap ? l_src : *r,
cond_swap ? *r : l_src);
} else {
- emit(ir, TGSI_OPCODE_CMP, *l, *cond,
+ emit_asm(ir, TGSI_OPCODE_CMP, *l, *cond,
cond_swap ? l_src : *r,
cond_swap ? *r : l_src);
}
} else {
- emit(ir, TGSI_OPCODE_MOV, *l, *r);
+ emit_asm(ir, TGSI_OPCODE_MOV, *l, *r);
}
l->index++;
r->index++;
@@ -2679,7 +2757,7 @@ glsl_to_tgsi_visitor::visit(ir_assignment *ir)
*/
glsl_to_tgsi_instruction *inst, *new_inst;
inst = (glsl_to_tgsi_instruction *)this->instructions.get_tail();
- new_inst = emit(ir, inst->op, l, inst->src[0], inst->src[1], inst->src[2]);
+ new_inst = emit_asm(ir, inst->op, l, inst->src[0], inst->src[1], inst->src[2]);
new_inst->saturate = inst->saturate;
inst->dead_mask = inst->dst[0].writemask;
} else {
@@ -2717,7 +2795,7 @@ glsl_to_tgsi_visitor::visit(ir_constant *ir)
src = this->result;
for (i = 0; i < (unsigned int)size; i++) {
- emit(ir, TGSI_OPCODE_MOV, temp, src);
+ emit_asm(ir, TGSI_OPCODE_MOV, temp, src);
src.index++;
temp.index++;
@@ -2739,7 +2817,7 @@ glsl_to_tgsi_visitor::visit(ir_constant *ir)
ir->array_elements[i]->accept(this);
src = this->result;
for (int j = 0; j < size; j++) {
- emit(ir, TGSI_OPCODE_MOV, temp, src);
+ emit_asm(ir, TGSI_OPCODE_MOV, temp, src);
src.index++;
temp.index++;
@@ -2764,7 +2842,7 @@ glsl_to_tgsi_visitor::visit(ir_constant *ir)
ir->type->vector_elements,
GL_FLOAT,
&src.swizzle);
- emit(ir, TGSI_OPCODE_MOV, mat_column, src);
+ emit_asm(ir, TGSI_OPCODE_MOV, mat_column, src);
mat_column.index++;
}
@@ -2889,7 +2967,7 @@ glsl_to_tgsi_visitor::visit(ir_call *ir)
l.cond_mask = COND_TR;
for (i = 0; i < type_size(param->type); i++) {
- emit(ir, TGSI_OPCODE_MOV, l, r);
+ emit_asm(ir, TGSI_OPCODE_MOV, l, r);
l.index++;
r.index++;
}
@@ -2897,7 +2975,7 @@ glsl_to_tgsi_visitor::visit(ir_call *ir)
}
/* Emit call instruction */
- call_inst = emit(ir, TGSI_OPCODE_CAL);
+ call_inst = emit_asm(ir, TGSI_OPCODE_CAL);
call_inst->function = entry;
/* Process out parameters. */
@@ -2922,7 +3000,7 @@ glsl_to_tgsi_visitor::visit(ir_call *ir)
st_dst_reg l = st_dst_reg(this->result);
for (i = 0; i < type_size(param->type); i++) {
- emit(ir, TGSI_OPCODE_MOV, l, r);
+ emit_asm(ir, TGSI_OPCODE_MOV, l, r);
l.index++;
r.index++;
}
@@ -2965,7 +3043,7 @@ glsl_to_tgsi_visitor::visit(ir_texture *ir)
coord = get_temp(glsl_type::vec4_type);
coord_dst = st_dst_reg(coord);
coord_dst.writemask = (1 << ir->coordinate->type->vector_elements) - 1;
- emit(ir, TGSI_OPCODE_MOV, coord_dst, this->result);
+ emit_asm(ir, TGSI_OPCODE_MOV, coord_dst, this->result);
}
if (ir->projector) {
@@ -3074,7 +3152,7 @@ glsl_to_tgsi_visitor::visit(ir_texture *ir)
if (opcode == TGSI_OPCODE_TEX) {
/* Slot the projector in as the last component of the coord. */
coord_dst.writemask = WRITEMASK_W;
- emit(ir, TGSI_OPCODE_MOV, coord_dst, projector);
+ emit_asm(ir, TGSI_OPCODE_MOV, coord_dst, projector);
coord_dst.writemask = WRITEMASK_XYZW;
opcode = TGSI_OPCODE_TXP;
} else {
@@ -3086,7 +3164,7 @@ glsl_to_tgsi_visitor::visit(ir_texture *ir)
* projective divide now.
*/
coord_dst.writemask = WRITEMASK_W;
- emit(ir, TGSI_OPCODE_RCP, coord_dst, projector);
+ emit_asm(ir, TGSI_OPCODE_RCP, coord_dst, projector);
/* In the case where we have to project the coordinates "by hand,"
* the shadow comparator value must also be projected.
@@ -3105,14 +3183,14 @@ glsl_to_tgsi_visitor::visit(ir_texture *ir)
assert(!sampler_type->sampler_array);
tmp_dst.writemask = WRITEMASK_Z;
- emit(ir, TGSI_OPCODE_MOV, tmp_dst, this->result);
+ emit_asm(ir, TGSI_OPCODE_MOV, tmp_dst, this->result);
tmp_dst.writemask = WRITEMASK_XY;
- emit(ir, TGSI_OPCODE_MOV, tmp_dst, coord);
+ emit_asm(ir, TGSI_OPCODE_MOV, tmp_dst, coord);
}
coord_dst.writemask = WRITEMASK_XYZ;
- emit(ir, TGSI_OPCODE_MUL, coord_dst, tmp_src, coord_w);
+ emit_asm(ir, TGSI_OPCODE_MUL, coord_dst, tmp_src, coord_w);
coord_dst.writemask = WRITEMASK_XYZW;
coord.swizzle = SWIZZLE_XYZW;
@@ -3133,7 +3211,7 @@ glsl_to_tgsi_visitor::visit(ir_texture *ir)
cube_sc = get_temp(glsl_type::float_type);
cube_sc_dst = st_dst_reg(cube_sc);
cube_sc_dst.writemask = WRITEMASK_X;
- emit(ir, TGSI_OPCODE_MOV, cube_sc_dst, this->result);
+ emit_asm(ir, TGSI_OPCODE_MOV, cube_sc_dst, this->result);
cube_sc_dst.writemask = WRITEMASK_X;
}
else {
@@ -3144,20 +3222,20 @@ glsl_to_tgsi_visitor::visit(ir_texture *ir)
} else {
coord_dst.writemask = WRITEMASK_Z;
}
- emit(ir, TGSI_OPCODE_MOV, coord_dst, this->result);
+ emit_asm(ir, TGSI_OPCODE_MOV, coord_dst, this->result);
coord_dst.writemask = WRITEMASK_XYZW;
}
}
if (ir->op == ir_txf_ms) {
coord_dst.writemask = WRITEMASK_W;
- emit(ir, TGSI_OPCODE_MOV, coord_dst, sample_index);
+ emit_asm(ir, TGSI_OPCODE_MOV, coord_dst, sample_index);
coord_dst.writemask = WRITEMASK_XYZW;
} else if (opcode == TGSI_OPCODE_TXL || opcode == TGSI_OPCODE_TXB ||
opcode == TGSI_OPCODE_TXF) {
/* TGSI stores LOD or LOD bias in the last channel of the coords. */
coord_dst.writemask = WRITEMASK_W;
- emit(ir, TGSI_OPCODE_MOV, coord_dst, lod_info);
+ emit_asm(ir, TGSI_OPCODE_MOV, coord_dst, lod_info);
coord_dst.writemask = WRITEMASK_XYZW;
}
@@ -3167,30 +3245,30 @@ glsl_to_tgsi_visitor::visit(ir_texture *ir)
}
if (opcode == TGSI_OPCODE_TXD)
- inst = emit(ir, opcode, result_dst, coord, dx, dy);
+ inst = emit_asm(ir, opcode, result_dst, coord, dx, dy);
else if (opcode == TGSI_OPCODE_TXQ) {
if (ir->op == ir_query_levels) {
/* the level is stored in W */
- inst = emit(ir, opcode, st_dst_reg(levels_src), lod_info);
+ inst = emit_asm(ir, opcode, st_dst_reg(levels_src), lod_info);
result_dst.writemask = WRITEMASK_X;
levels_src.swizzle = SWIZZLE_WWWW;
- emit(ir, TGSI_OPCODE_MOV, result_dst, levels_src);
+ emit_asm(ir, TGSI_OPCODE_MOV, result_dst, levels_src);
} else
- inst = emit(ir, opcode, result_dst, lod_info);
+ inst = emit_asm(ir, opcode, result_dst, lod_info);
} else if (opcode == TGSI_OPCODE_TXF) {
- inst = emit(ir, opcode, result_dst, coord);
+ inst = emit_asm(ir, opcode, result_dst, coord);
} else if (opcode == TGSI_OPCODE_TXL2 || opcode == TGSI_OPCODE_TXB2) {
- inst = emit(ir, opcode, result_dst, coord, lod_info);
+ inst = emit_asm(ir, opcode, result_dst, coord, lod_info);
} else if (opcode == TGSI_OPCODE_TEX2) {
- inst = emit(ir, opcode, result_dst, coord, cube_sc);
+ inst = emit_asm(ir, opcode, result_dst, coord, cube_sc);
} else if (opcode == TGSI_OPCODE_TG4) {
if (is_cube_array && ir->shadow_comparitor) {
- inst = emit(ir, opcode, result_dst, coord, cube_sc);
+ inst = emit_asm(ir, opcode, result_dst, coord, cube_sc);
} else {
- inst = emit(ir, opcode, result_dst, coord, component);
+ inst = emit_asm(ir, opcode, result_dst, coord, component);
}
} else
- inst = emit(ir, opcode, result_dst, coord);
+ inst = emit_asm(ir, opcode, result_dst, coord);
if (ir->shadow_comparitor)
inst->tex_shadow = GL_TRUE;
@@ -3264,13 +3342,13 @@ glsl_to_tgsi_visitor::visit(ir_return *ir)
l = st_dst_reg(current_function->return_reg);
for (i = 0; i < type_size(current_function->sig->return_type); i++) {
- emit(ir, TGSI_OPCODE_MOV, l, r);
+ emit_asm(ir, TGSI_OPCODE_MOV, l, r);
l.index++;
r.index++;
}
}
- emit(ir, TGSI_OPCODE_RET);
+ emit_asm(ir, TGSI_OPCODE_RET);
}
void
@@ -3283,16 +3361,16 @@ glsl_to_tgsi_visitor::visit(ir_discard *ir)
/* Convert the bool condition to a float so we can negate. */
if (native_integers) {
st_src_reg temp = get_temp(ir->condition->type);
- emit(ir, TGSI_OPCODE_AND, st_dst_reg(temp),
+ emit_asm(ir, TGSI_OPCODE_AND, st_dst_reg(temp),
condition, st_src_reg_for_float(1.0));
condition = temp;
}
condition.negate = ~condition.negate;
- emit(ir, TGSI_OPCODE_KILL_IF, undef_dst, condition);
+ emit_asm(ir, TGSI_OPCODE_KILL_IF, undef_dst, condition);
} else {
/* unconditional kil */
- emit(ir, TGSI_OPCODE_KILL);
+ emit_asm(ir, TGSI_OPCODE_KILL);
}
}
@@ -3307,18 +3385,18 @@ glsl_to_tgsi_visitor::visit(ir_if *ir)
if_opcode = native_integers ? TGSI_OPCODE_UIF : TGSI_OPCODE_IF;
- if_inst = emit(ir->condition, if_opcode, undef_dst, this->result);
+ if_inst = emit_asm(ir->condition, if_opcode, undef_dst, this->result);
this->instructions.push_tail(if_inst);
visit_exec_list(&ir->then_instructions, this);
if (!ir->else_instructions.is_empty()) {
- emit(ir->condition, TGSI_OPCODE_ELSE);
+ emit_asm(ir->condition, TGSI_OPCODE_ELSE);
visit_exec_list(&ir->else_instructions, this);
}
- if_inst = emit(ir->condition, TGSI_OPCODE_ENDIF);
+ if_inst = emit_asm(ir->condition, TGSI_OPCODE_ENDIF);
}
@@ -3328,7 +3406,7 @@ glsl_to_tgsi_visitor::visit(ir_emit_vertex *ir)
assert(this->prog->Target == GL_GEOMETRY_PROGRAM_NV);
ir->stream->accept(this);
- emit(ir, TGSI_OPCODE_EMIT, undef_dst, this->result);
+ emit_asm(ir, TGSI_OPCODE_EMIT, undef_dst, this->result);
}
void
@@ -3337,14 +3415,24 @@ glsl_to_tgsi_visitor::visit(ir_end_primitive *ir)
assert(this->prog->Target == GL_GEOMETRY_PROGRAM_NV);
ir->stream->accept(this);
- emit(ir, TGSI_OPCODE_ENDPRIM, undef_dst, this->result);
+ emit_asm(ir, TGSI_OPCODE_ENDPRIM, undef_dst, this->result);
+}
+
+void
+glsl_to_tgsi_visitor::visit(ir_barrier *ir)
+{
+ unreachable("Not implemented!");
}
glsl_to_tgsi_visitor::glsl_to_tgsi_visitor()
{
result.file = PROGRAM_UNDEFINED;
next_temp = 1;
+ array_sizes = NULL;
+ max_num_arrays = 0;
next_array = 0;
+ num_input_arrays = 0;
+ num_output_arrays = 0;
next_signature_id = 1;
num_immediates = 0;
current_function = NULL;
@@ -3366,6 +3454,7 @@ glsl_to_tgsi_visitor::glsl_to_tgsi_visitor()
glsl_to_tgsi_visitor::~glsl_to_tgsi_visitor()
{
+ free(array_sizes);
ralloc_free(mem_ctx);
}
@@ -3734,6 +3823,7 @@ glsl_to_tgsi_visitor::copy_propagate(void)
inst->src[r].index2D = first->src[0].index2D;
inst->src[r].has_index2 = first->src[0].has_index2;
inst->src[r].double_reg2 = first->src[0].double_reg2;
+ inst->src[r].array_id = first->src[0].array_id;
int swizzle = 0;
for (int i = 0; i < 4; i++) {
@@ -4177,7 +4267,7 @@ get_pixel_transfer_visitor(struct st_fragment_program *fp,
coord = st_src_reg(PROGRAM_INPUT, VARYING_SLOT_TEX0, glsl_type::vec2_type);
src0 = v->get_temp(glsl_type::vec4_type);
dst0 = st_dst_reg(src0);
- inst = v->emit(NULL, TGSI_OPCODE_TEX, dst0, coord);
+ inst = v->emit_asm(NULL, TGSI_OPCODE_TEX, dst0, coord);
inst->sampler_array_size = 1;
inst->tex_target = TEXTURE_2D_INDEX;
@@ -4201,7 +4291,7 @@ get_pixel_transfer_visitor(struct st_fragment_program *fp,
/* MAD colorTemp, colorTemp, scale, bias; */
scale = st_src_reg(PROGRAM_STATE_VAR, scale_p, GLSL_TYPE_FLOAT);
bias = st_src_reg(PROGRAM_STATE_VAR, bias_p, GLSL_TYPE_FLOAT);
- inst = v->emit(NULL, TGSI_OPCODE_MAD, dst0, src0, scale, bias);
+ inst = v->emit_asm(NULL, TGSI_OPCODE_MAD, dst0, src0, scale, bias);
}
if (pixel_maps) {
@@ -4209,6 +4299,7 @@ get_pixel_transfer_visitor(struct st_fragment_program *fp,
st_dst_reg temp_dst = st_dst_reg(temp);
assert(st->pixel_xfer.pixelmap_texture);
+ (void) st;
/* With a little effort, we can do four pixel map look-ups with
* two TEX instructions:
@@ -4216,7 +4307,7 @@ get_pixel_transfer_visitor(struct st_fragment_program *fp,
/* TEX temp.rg, colorTemp.rgba, texture[1], 2D; */
temp_dst.writemask = WRITEMASK_XY; /* write R,G */
- inst = v->emit(NULL, TGSI_OPCODE_TEX, temp_dst, src0);
+ inst = v->emit_asm(NULL, TGSI_OPCODE_TEX, temp_dst, src0);
inst->sampler.index = 1;
inst->sampler_array_size = 1;
inst->tex_target = TEXTURE_2D_INDEX;
@@ -4224,7 +4315,7 @@ get_pixel_transfer_visitor(struct st_fragment_program *fp,
/* TEX temp.ba, colorTemp.baba, texture[1], 2D; */
src0.swizzle = MAKE_SWIZZLE4(SWIZZLE_Z, SWIZZLE_W, SWIZZLE_Z, SWIZZLE_W);
temp_dst.writemask = WRITEMASK_ZW; /* write B,A */
- inst = v->emit(NULL, TGSI_OPCODE_TEX, temp_dst, src0);
+ inst = v->emit_asm(NULL, TGSI_OPCODE_TEX, temp_dst, src0);
inst->sampler.index = 1;
inst->sampler_array_size = 1;
inst->tex_target = TEXTURE_2D_INDEX;
@@ -4233,7 +4324,7 @@ get_pixel_transfer_visitor(struct st_fragment_program *fp,
v->samplers_used |= (1 << 1);
/* MOV colorTemp, temp; */
- inst = v->emit(NULL, TGSI_OPCODE_MOV, dst0, temp);
+ inst = v->emit_asm(NULL, TGSI_OPCODE_MOV, dst0, temp);
}
/* Now copy the instructions from the original glsl_to_tgsi_visitor into the
@@ -4256,7 +4347,7 @@ get_pixel_transfer_visitor(struct st_fragment_program *fp,
prog->InputsRead |= BITFIELD64_BIT(src_regs[i].index);
}
- newinst = v->emit(NULL, inst->op, inst->dst[0], src_regs[0], src_regs[1], src_regs[2]);
+ newinst = v->emit_asm(NULL, inst->op, inst->dst[0], src_regs[0], src_regs[1], src_regs[2]);
newinst->tex_target = inst->tex_target;
newinst->sampler_array_size = inst->sampler_array_size;
}
@@ -4306,7 +4397,7 @@ get_bitmap_visitor(struct st_fragment_program *fp,
coord = st_src_reg(PROGRAM_INPUT, VARYING_SLOT_TEX0, glsl_type::vec2_type);
src0 = v->get_temp(glsl_type::vec4_type);
dst0 = st_dst_reg(src0);
- inst = v->emit(NULL, TGSI_OPCODE_TEX, dst0, coord);
+ inst = v->emit_asm(NULL, TGSI_OPCODE_TEX, dst0, coord);
inst->sampler.index = samplerIndex;
inst->sampler_array_size = 1;
inst->tex_target = TEXTURE_2D_INDEX;
@@ -4319,7 +4410,7 @@ get_bitmap_visitor(struct st_fragment_program *fp,
src0.negate = NEGATE_XYZW;
if (st->bitmap.tex_format == PIPE_FORMAT_L8_UNORM)
src0.swizzle = SWIZZLE_XXXX;
- inst = v->emit(NULL, TGSI_OPCODE_KILL_IF, undef_dst, src0);
+ inst = v->emit_asm(NULL, TGSI_OPCODE_KILL_IF, undef_dst, src0);
/* Now copy the instructions from the original glsl_to_tgsi_visitor into the
* new visitor. */
@@ -4336,7 +4427,7 @@ get_bitmap_visitor(struct st_fragment_program *fp,
prog->InputsRead |= BITFIELD64_BIT(src_regs[i].index);
}
- newinst = v->emit(NULL, inst->op, inst->dst[0], src_regs[0], src_regs[1], src_regs[2]);
+ newinst = v->emit_asm(NULL, inst->op, inst->dst[0], src_regs[0], src_regs[1], src_regs[2]);
newinst->tex_target = inst->tex_target;
newinst->sampler_array_size = inst->sampler_array_size;
}
@@ -4362,7 +4453,8 @@ struct st_translate {
unsigned temps_size;
struct ureg_dst *temps;
- struct ureg_dst arrays[MAX_ARRAYS];
+ struct ureg_dst *arrays;
+ unsigned num_temp_arrays;
struct ureg_src *constants;
int num_constants;
struct ureg_src *immediates;
@@ -4373,7 +4465,9 @@ struct st_translate {
struct ureg_src samplers[PIPE_MAX_SAMPLERS];
struct ureg_src systemValues[SYSTEM_VALUE_MAX];
struct tgsi_texture_offset tex_offsets[MAX_GLSL_TEXTURE_OFFSET];
- unsigned array_sizes[MAX_ARRAYS];
+ unsigned *array_sizes;
+ struct array_decl *input_arrays;
+ struct array_decl *output_arrays;
const GLuint *inputMapping;
const GLuint *outputMapping;
@@ -4497,9 +4591,8 @@ emit_immediate(struct st_translate *t,
* Map a glsl_to_tgsi dst register to a TGSI ureg_dst register.
*/
static struct ureg_dst
-dst_register(struct st_translate *t,
- gl_register_file file,
- GLuint index)
+dst_register(struct st_translate *t, gl_register_file file, unsigned index,
+ unsigned array_id)
{
unsigned array;
@@ -4530,7 +4623,7 @@ dst_register(struct st_translate *t,
case PROGRAM_ARRAY:
array = index >> 16;
- assert(array < ARRAY_SIZE(t->arrays));
+ assert(array < t->num_temp_arrays);
if (ureg_dst_is_undef(t->arrays[array]))
t->arrays[array] = ureg_DECL_array_temporary(
@@ -4540,16 +4633,25 @@ dst_register(struct st_translate *t,
(int)(index & 0xFFFF) - 0x8000);
case PROGRAM_OUTPUT:
- if (t->procType == TGSI_PROCESSOR_VERTEX)
- assert(index < VARYING_SLOT_MAX);
- else if (t->procType == TGSI_PROCESSOR_FRAGMENT)
- assert(index < FRAG_RESULT_MAX);
- else
- assert(index < VARYING_SLOT_MAX);
+ if (!array_id) {
+ if (t->procType == TGSI_PROCESSOR_FRAGMENT)
+ assert(index < FRAG_RESULT_MAX);
+ else
+ assert(index < VARYING_SLOT_MAX);
- assert(t->outputMapping[index] < ARRAY_SIZE(t->outputs));
+ assert(t->outputMapping[index] < ARRAY_SIZE(t->outputs));
+ assert(t->outputs[t->outputMapping[index]].File != TGSI_FILE_NULL);
+ return t->outputs[t->outputMapping[index]];
+ }
+ else {
+ struct array_decl *decl = &t->output_arrays[array_id-1];
+ unsigned mesa_index = decl->mesa_index;
+ int slot = t->outputMapping[mesa_index];
- return t->outputs[t->outputMapping[index]];
+ assert(slot != -1 && t->outputs[slot].File == TGSI_FILE_OUTPUT);
+ assert(t->outputs[slot].ArrayID == array_id);
+ return ureg_dst_array_offset(t->outputs[slot], index - mesa_index);
+ }
case PROGRAM_ADDRESS:
return t->address[index];
@@ -4575,7 +4677,8 @@ src_register(struct st_translate *t, const st_src_reg *reg)
case PROGRAM_TEMPORARY:
case PROGRAM_ARRAY:
- return ureg_src(dst_register(t, reg->file, reg->index));
+ case PROGRAM_OUTPUT:
+ return ureg_src(dst_register(t, reg->file, reg->index, reg->array_id));
case PROGRAM_UNIFORM:
assert(reg->index >= 0);
@@ -4598,12 +4701,20 @@ src_register(struct st_translate *t, const st_src_reg *reg)
* map back to the original index and add the offset after
* mapping. */
index -= double_reg2;
- assert(t->inputMapping[index] < ARRAY_SIZE(t->inputs));
- return t->inputs[t->inputMapping[index] + double_reg2];
+ if (!reg->array_id) {
+ assert(t->inputMapping[index] < ARRAY_SIZE(t->inputs));
+ assert(t->inputs[t->inputMapping[index]].File != TGSI_FILE_NULL);
+ return t->inputs[t->inputMapping[index]];
+ }
+ else {
+ struct array_decl *decl = &t->input_arrays[reg->array_id-1];
+ unsigned mesa_index = decl->mesa_index;
+ int slot = t->inputMapping[mesa_index];
- case PROGRAM_OUTPUT:
- assert(t->outputMapping[reg->index] < ARRAY_SIZE(t->outputs));
- return ureg_src(t->outputs[t->outputMapping[reg->index]]); /* not needed? */
+ assert(slot != -1 && t->inputs[slot].File == TGSI_FILE_INPUT);
+ assert(t->inputs[slot].ArrayID == reg->array_id);
+ return ureg_src_array_offset(t->inputs[slot], index - mesa_index);
+ }
case PROGRAM_ADDRESS:
return ureg_src(t->address[reg->index]);
@@ -4626,9 +4737,8 @@ translate_dst(struct st_translate *t,
const st_dst_reg *dst_reg,
bool saturate, bool clamp_color)
{
- struct ureg_dst dst = dst_register(t,
- dst_reg->file,
- dst_reg->index);
+ struct ureg_dst dst = dst_register(t, dst_reg->file, dst_reg->index,
+ dst_reg->array_id);
if (dst.File == TGSI_FILE_NULL)
return dst;
@@ -4738,7 +4848,7 @@ translate_tex_offset(struct st_translate *t,
array = in_offset->index >> 16;
assert(array >= 0);
- assert(array < (int) ARRAY_SIZE(t->arrays));
+ assert(array < (int)t->num_temp_arrays);
dst = t->arrays[array];
offset.File = dst.File;
@@ -5060,6 +5170,25 @@ emit_edgeflags(struct st_translate *t)
ureg_MOV(ureg, edge_dst, edge_src);
}
+static bool
+find_array(unsigned attr, struct array_decl *arrays, unsigned count,
+ unsigned *array_id, unsigned *array_size)
+{
+ unsigned i;
+
+ for (i = 0; i < count; i++) {
+ struct array_decl *decl = &arrays[i];
+
+ if (attr == decl->mesa_index) {
+ *array_id = decl->array_id;
+ *array_size = decl->array_size;
+ assert(*array_size);
+ return true;
+ }
+ }
+ return false;
+}
+
/**
* Translate intermediate IR (glsl_to_tgsi_instruction) to TGSI format.
* \param program the program to translate
@@ -5089,12 +5218,14 @@ st_translate_program(
const struct gl_program *proginfo,
GLuint numInputs,
const GLuint inputMapping[],
+ const GLuint inputSlotToAttr[],
const ubyte inputSemanticName[],
const ubyte inputSemanticIndex[],
const GLuint interpMode[],
const GLuint interpLocation[],
GLuint numOutputs,
const GLuint outputMapping[],
+ const GLuint outputSlotToAttr[],
const ubyte outputSemanticName[],
const ubyte outputSemanticIndex[],
boolean passthrough_edgeflags,
@@ -5132,25 +5263,101 @@ st_translate_program(
goto out;
}
- memset(t, 0, sizeof *t);
-
t->procType = procType;
t->inputMapping = inputMapping;
t->outputMapping = outputMapping;
t->ureg = ureg;
+ t->num_temp_arrays = program->next_array;
+ if (t->num_temp_arrays)
+ t->arrays = (struct ureg_dst*)
+ calloc(1, sizeof(t->arrays[0]) * t->num_temp_arrays);
/*
* Declare input attributes.
*/
- if (procType == TGSI_PROCESSOR_FRAGMENT) {
+ switch (procType) {
+ case TGSI_PROCESSOR_FRAGMENT:
for (i = 0; i < numInputs; i++) {
- t->inputs[i] = ureg_DECL_fs_input_cyl_centroid(ureg,
- inputSemanticName[i],
- inputSemanticIndex[i],
- interpMode[i], 0,
- interpLocation[i]);
+ unsigned array_id = 0;
+ unsigned array_size;
+
+ if (find_array(inputSlotToAttr[i], program->input_arrays,
+ program->num_input_arrays, &array_id, &array_size)) {
+ /* We've found an array. Declare it so. */
+ t->inputs[i] = ureg_DECL_fs_input_cyl_centroid(ureg,
+ inputSemanticName[i], inputSemanticIndex[i],
+ interpMode[i], 0, interpLocation[i],
+ array_id, array_size);
+ i += array_size - 1;
+ }
+ else {
+ t->inputs[i] = ureg_DECL_fs_input_cyl_centroid(ureg,
+ inputSemanticName[i], inputSemanticIndex[i],
+ interpMode[i], 0, interpLocation[i], 0, 1);
+ }
}
+ break;
+ case TGSI_PROCESSOR_GEOMETRY:
+ for (i = 0; i < numInputs; i++) {
+ unsigned array_id = 0;
+ unsigned array_size;
+
+ if (find_array(inputSlotToAttr[i], program->input_arrays,
+ program->num_input_arrays, &array_id, &array_size)) {
+ /* We've found an array. Declare it so. */
+ t->inputs[i] = ureg_DECL_input(ureg, inputSemanticName[i],
+ inputSemanticIndex[i],
+ array_id, array_size);
+ i += array_size - 1;
+ }
+ else {
+ t->inputs[i] = ureg_DECL_input(ureg, inputSemanticName[i],
+ inputSemanticIndex[i], 0, 1);
+ }
+ }
+ break;
+ case TGSI_PROCESSOR_VERTEX:
+ for (i = 0; i < numInputs; i++) {
+ t->inputs[i] = ureg_DECL_vs_input(ureg, i);
+ }
+ break;
+ default:
+ assert(0);
+ }
+ /*
+ * Declare output attributes.
+ */
+ switch (procType) {
+ case TGSI_PROCESSOR_FRAGMENT:
+ break;
+ case TGSI_PROCESSOR_GEOMETRY:
+ case TGSI_PROCESSOR_VERTEX:
+ for (i = 0; i < numOutputs; i++) {
+ unsigned array_id = 0;
+ unsigned array_size;
+
+ if (find_array(outputSlotToAttr[i], program->output_arrays,
+ program->num_output_arrays, &array_id, &array_size)) {
+ /* We've found an array. Declare it so. */
+ t->outputs[i] = ureg_DECL_output_array(ureg,
+ outputSemanticName[i],
+ outputSemanticIndex[i],
+ array_id, array_size);
+ i += array_size - 1;
+ }
+ else {
+ t->outputs[i] = ureg_DECL_output(ureg,
+ outputSemanticName[i],
+ outputSemanticIndex[i]);
+ }
+ }
+ break;
+ default:
+ assert(0);
+ }
+
+ if (procType == TGSI_PROCESSOR_FRAGMENT) {
if (proginfo->InputsRead & VARYING_BIT_POS) {
/* Must do this after setting up t->inputs. */
emit_wpos(st_context(ctx), t, proginfo, ureg,
@@ -5160,9 +5367,6 @@ st_translate_program(
if (proginfo->InputsRead & VARYING_BIT_FACE)
emit_face_var(ctx, t);
- /*
- * Declare output attributes.
- */
for (i = 0; i < numOutputs; i++) {
switch (outputSemanticName[i]) {
case TGSI_SEMANTIC_POSITION:
@@ -5198,31 +5402,8 @@ st_translate_program(
}
}
}
- else if (procType == TGSI_PROCESSOR_GEOMETRY) {
- for (i = 0; i < numInputs; i++) {
- t->inputs[i] = ureg_DECL_gs_input(ureg,
- i,
- inputSemanticName[i],
- inputSemanticIndex[i]);
- }
-
+ else if (procType == TGSI_PROCESSOR_VERTEX) {
for (i = 0; i < numOutputs; i++) {
- t->outputs[i] = ureg_DECL_output(ureg,
- outputSemanticName[i],
- outputSemanticIndex[i]);
- }
- }
- else {
- assert(procType == TGSI_PROCESSOR_VERTEX);
-
- for (i = 0; i < numInputs; i++) {
- t->inputs[i] = ureg_DECL_vs_input(ureg, i);
- }
-
- for (i = 0; i < numOutputs; i++) {
- t->outputs[i] = ureg_DECL_output(ureg,
- outputSemanticName[i],
- outputSemanticIndex[i]);
if (outputSemanticName[i] == TGSI_SEMANTIC_FOG) {
/* force register to contain a fog coordinate in the form (F, 0, 0, 1). */
ureg_MOV(ureg,
@@ -5277,9 +5458,9 @@ st_translate_program(
}
}
- /* Copy over array sizes
- */
- memcpy(t->array_sizes, program->array_sizes, sizeof(unsigned) * program->next_array);
+ t->array_sizes = program->array_sizes;
+ t->input_arrays = program->input_arrays;
+ t->output_arrays = program->output_arrays;
/* Emit constants and uniforms. TGSI uses a single index space for these,
* so we put all the translated regs in t->constants.
@@ -5375,6 +5556,7 @@ st_translate_program(
out:
if (t) {
+ free(t->arrays);
free(t->temps);
free(t->insn);
free(t->labels);
@@ -5470,7 +5652,7 @@ get_mesa_program(struct gl_context *ctx,
if (!entry->bgn_inst) {
v->current_function = entry;
- entry->bgn_inst = v->emit(NULL, TGSI_OPCODE_BGNSUB);
+ entry->bgn_inst = v->emit_asm(NULL, TGSI_OPCODE_BGNSUB);
entry->bgn_inst->function = entry;
visit_exec_list(&entry->sig->body, v);
@@ -5478,10 +5660,10 @@ get_mesa_program(struct gl_context *ctx,
glsl_to_tgsi_instruction *last;
last = (glsl_to_tgsi_instruction *)v->instructions.get_tail();
if (last->op != TGSI_OPCODE_RET)
- v->emit(NULL, TGSI_OPCODE_RET);
+ v->emit_asm(NULL, TGSI_OPCODE_RET);
glsl_to_tgsi_instruction *end;
- end = v->emit(NULL, TGSI_OPCODE_ENDSUB);
+ end = v->emit_asm(NULL, TGSI_OPCODE_ENDSUB);
end->function = entry;
progress = GL_TRUE;
@@ -5513,7 +5695,7 @@ get_mesa_program(struct gl_context *ctx,
v->renumber_registers();
/* Write the END instruction. */
- v->emit(NULL, TGSI_OPCODE_END);
+ v->emit_asm(NULL, TGSI_OPCODE_END);
if (ctx->_Shader->Flags & GLSL_DUMP) {
_mesa_log("\n");
@@ -5528,6 +5710,10 @@ get_mesa_program(struct gl_context *ctx,
prog->NumInstructions = 0;
do_set_program_inouts(shader->ir, prog, shader->Stage);
+ shrink_array_declarations(v->input_arrays, v->num_input_arrays,
+ prog->InputsRead);
+ shrink_array_declarations(v->output_arrays, v->num_output_arrays,
+ prog->OutputsWritten);
count_resources(v, prog);
/* This must be done before the uniform storage is associated. */
@@ -5549,6 +5735,7 @@ get_mesa_program(struct gl_context *ctx,
*/
_mesa_associate_uniform_storage(ctx, shader_program, prog->Parameters);
if (!shader_program->LinkStatus) {
+ free_glsl_to_tgsi_visitor(v);
return NULL;
}
diff --git a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.h b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.h
index 2cb80bcf9..4af747fa9 100644
--- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.h
+++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.h
@@ -43,12 +43,14 @@ enum pipe_error st_translate_program(
const struct gl_program *proginfo,
GLuint numInputs,
const GLuint inputMapping[],
+ const GLuint inputSlotToAttr[],
const ubyte inputSemanticName[],
const ubyte inputSemanticIndex[],
const GLuint interpMode[],
const GLuint interpLocation[],
GLuint numOutputs,
const GLuint outputMapping[],
+ const GLuint outputSlotToAttr[],
const ubyte outputSemanticName[],
const ubyte outputSemanticIndex[],
boolean passthrough_edgeflags,
diff --git a/mesalib/src/mesa/state_tracker/st_manager.c b/mesalib/src/mesa/state_tracker/st_manager.c
index 0376954f7..a2dee6298 100644
--- a/mesalib/src/mesa/state_tracker/st_manager.c
+++ b/mesalib/src/mesa/state_tracker/st_manager.c
@@ -924,8 +924,7 @@ static unsigned get_version(struct pipe_screen *screen,
struct gl_extensions extensions = {0};
GLuint version;
- if ((api == API_OPENGL_COMPAT || api == API_OPENGL_CORE) &&
- _mesa_override_gl_version_contextless(&consts, &api, &version)) {
+ if (_mesa_override_gl_version_contextless(&consts, &api, &version)) {
return version;
}
diff --git a/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c b/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c
index 98d525c86..896e239ee 100644
--- a/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c
+++ b/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c
@@ -665,7 +665,7 @@ compile_instruction(
if (num_dst)
dst[0] = translate_dst( t,
&inst->DstReg,
- inst->SaturateMode,
+ inst->Saturate,
clamp_dst_color_output);
for (i = 0; i < num_src; i++)
@@ -1095,10 +1095,9 @@ st_translate_mesa_program(
}
else if (procType == TGSI_PROCESSOR_GEOMETRY) {
for (i = 0; i < numInputs; i++) {
- t->inputs[i] = ureg_DECL_gs_input(ureg,
- i,
- inputSemanticName[i],
- inputSemanticIndex[i]);
+ t->inputs[i] = ureg_DECL_input(ureg,
+ inputSemanticName[i],
+ inputSemanticIndex[i], 0, 1);
}
for (i = 0; i < numOutputs; i++) {
diff --git a/mesalib/src/mesa/state_tracker/st_program.c b/mesalib/src/mesa/state_tracker/st_program.c
index a9110d3c6..d5a124f21 100644
--- a/mesalib/src/mesa/state_tracker/st_program.c
+++ b/mesalib/src/mesa/state_tracker/st_program.c
@@ -215,6 +215,7 @@ st_prepare_vertex_program(struct gl_context *ctx,
unsigned slot = stvp->num_outputs++;
stvp->result_to_output[attr] = slot;
+ stvp->output_slot_to_attr[slot] = attr;
switch (attr) {
case VARYING_SLOT_POS:
@@ -321,7 +322,7 @@ st_translate_vertex_program(struct st_context *st,
_mesa_remove_output_reads(&stvp->Base.Base, PROGRAM_OUTPUT);
}
- ureg = ureg_create( TGSI_PROCESSOR_VERTEX );
+ ureg = ureg_create_with_screen(TGSI_PROCESSOR_VERTEX, st->pipe->screen);
if (ureg == NULL) {
free(vpv);
return NULL;
@@ -351,6 +352,7 @@ st_translate_vertex_program(struct st_context *st,
/* inputs */
vpv->num_inputs,
stvp->input_to_index,
+ NULL, /* inputSlotToAttr */
NULL, /* input semantic name */
NULL, /* input semantic index */
NULL, /* interp mode */
@@ -358,6 +360,7 @@ st_translate_vertex_program(struct st_context *st,
/* outputs */
num_outputs,
stvp->result_to_output,
+ stvp->output_slot_to_attr,
stvp->output_semantic_name,
stvp->output_semantic_index,
key->passthrough_edgeflags,
@@ -482,6 +485,7 @@ st_translate_fragment_program(struct st_context *st,
GLuint outputMapping[FRAG_RESULT_MAX];
GLuint inputMapping[VARYING_SLOT_MAX];
+ GLuint inputSlotToAttr[VARYING_SLOT_MAX];
GLuint interpMode[PIPE_MAX_SHADER_INPUTS]; /* XXX size? */
GLuint interpLocation[PIPE_MAX_SHADER_INPUTS];
GLuint attr;
@@ -502,6 +506,7 @@ st_translate_fragment_program(struct st_context *st,
return NULL;
assert(!(key->bitmap && key->drawpixels));
+ memset(inputSlotToAttr, ~0, sizeof(inputSlotToAttr));
if (key->bitmap) {
/* glBitmap drawing */
@@ -543,6 +548,7 @@ st_translate_fragment_program(struct st_context *st,
const GLuint slot = fs_num_inputs++;
inputMapping[attr] = slot;
+ inputSlotToAttr[slot] = attr;
if (stfp->Base.IsCentroid & BITFIELD64_BIT(attr))
interpLocation[slot] = TGSI_INTERPOLATE_LOC_CENTROID;
else if (stfp->Base.IsSample & BITFIELD64_BIT(attr))
@@ -732,7 +738,7 @@ st_translate_fragment_program(struct st_context *st,
}
}
- ureg = ureg_create( TGSI_PROCESSOR_FRAGMENT );
+ ureg = ureg_create_with_screen(TGSI_PROCESSOR_FRAGMENT, st->pipe->screen);
if (ureg == NULL) {
free(variant);
return NULL;
@@ -778,6 +784,7 @@ st_translate_fragment_program(struct st_context *st,
/* inputs */
fs_num_inputs,
inputMapping,
+ inputSlotToAttr,
input_semantic_name,
input_semantic_index,
interpMode,
@@ -785,6 +792,7 @@ st_translate_fragment_program(struct st_context *st,
/* outputs */
fs_num_outputs,
outputMapping,
+ NULL,
fs_output_semantic_name,
fs_output_semantic_index, FALSE,
key->clamp_color );
@@ -867,7 +875,9 @@ st_translate_geometry_program(struct st_context *st,
struct st_geometry_program *stgp,
const struct st_gp_variant_key *key)
{
+ GLuint inputSlotToAttr[VARYING_SLOT_MAX];
GLuint inputMapping[VARYING_SLOT_MAX];
+ GLuint outputSlotToAttr[VARYING_SLOT_MAX];
GLuint outputMapping[VARYING_SLOT_MAX];
struct pipe_context *pipe = st->pipe;
GLuint attr;
@@ -890,13 +900,15 @@ st_translate_geometry_program(struct st_context *st,
if (!gpv)
return NULL;
- ureg = ureg_create(TGSI_PROCESSOR_GEOMETRY);
+ ureg = ureg_create_with_screen(TGSI_PROCESSOR_GEOMETRY, st->pipe->screen);
if (ureg == NULL) {
free(gpv);
return NULL;
}
+ memset(inputSlotToAttr, 0, sizeof(inputSlotToAttr));
memset(inputMapping, 0, sizeof(inputMapping));
+ memset(outputSlotToAttr, 0, sizeof(outputSlotToAttr));
memset(outputMapping, 0, sizeof(outputMapping));
/*
@@ -907,6 +919,7 @@ st_translate_geometry_program(struct st_context *st,
const GLuint slot = gs_num_inputs++;
inputMapping[attr] = slot;
+ inputSlotToAttr[slot] = attr;
switch (attr) {
case VARYING_SLOT_PRIMITIVE_ID:
@@ -985,6 +998,7 @@ st_translate_geometry_program(struct st_context *st,
GLuint slot = gs_num_outputs++;
outputMapping[attr] = slot;
+ outputSlotToAttr[slot] = attr;
switch (attr) {
case VARYING_SLOT_POS:
@@ -1080,6 +1094,7 @@ st_translate_geometry_program(struct st_context *st,
/* inputs */
gs_num_inputs,
inputMapping,
+ inputSlotToAttr,
input_semantic_name,
input_semantic_index,
NULL,
@@ -1087,6 +1102,7 @@ st_translate_geometry_program(struct st_context *st,
/* outputs */
gs_num_outputs,
outputMapping,
+ outputSlotToAttr,
gs_output_semantic_name,
gs_output_semantic_index,
FALSE,
@@ -1201,7 +1217,7 @@ destroy_program_variants(struct st_context *st, struct gl_program *program)
}
}
break;
- case MESA_GEOMETRY_PROGRAM:
+ case GL_GEOMETRY_PROGRAM_NV:
{
struct st_geometry_program *stgp =
(struct st_geometry_program *) program;
diff --git a/mesalib/src/mesa/state_tracker/st_program.h b/mesalib/src/mesa/state_tracker/st_program.h
index a2c56062d..bb77eb6ed 100644
--- a/mesalib/src/mesa/state_tracker/st_program.h
+++ b/mesalib/src/mesa/state_tracker/st_program.h
@@ -163,6 +163,7 @@ struct st_vertex_program
/** Maps VARYING_SLOT_x to slot */
GLuint result_to_output[VARYING_SLOT_MAX];
+ GLuint output_slot_to_attr[VARYING_SLOT_MAX];
ubyte output_semantic_name[VARYING_SLOT_MAX];
ubyte output_semantic_index[VARYING_SLOT_MAX];
GLuint num_outputs;
diff --git a/mesalib/src/mesa/tnl/t_context.c b/mesalib/src/mesa/tnl/t_context.c
index 5b9dd54d7..bc77ba8bf 100644
--- a/mesalib/src/mesa/tnl/t_context.c
+++ b/mesalib/src/mesa/tnl/t_context.c
@@ -36,6 +36,7 @@
#include "math/m_xform.h"
#include "main/state.h"
#include "main/viewport.h"
+#include "util/simple_list.h"
#include "tnl.h"
#include "t_context.h"
diff --git a/mesalib/src/mesa/vbo/vbo_exec_array.c b/mesalib/src/mesa/vbo/vbo_exec_array.c
index 3ea775c0e..72b8206ec 100644
--- a/mesalib/src/mesa/vbo/vbo_exec_array.c
+++ b/mesalib/src/mesa/vbo/vbo_exec_array.c
@@ -1817,9 +1817,12 @@ vbo_initialize_exec_dispatch(const struct gl_context *ctx,
SET_DrawElementsInstancedBaseVertexBaseInstance(exec, vbo_exec_DrawElementsInstancedBaseVertexBaseInstance);
}
- if (ctx->API == API_OPENGL_CORE) {
+ if (ctx->API == API_OPENGL_CORE || _mesa_is_gles31(ctx)) {
SET_DrawArraysIndirect(exec, vbo_exec_DrawArraysIndirect);
SET_DrawElementsIndirect(exec, vbo_exec_DrawElementsIndirect);
+ }
+
+ if (ctx->API == API_OPENGL_CORE) {
SET_MultiDrawArraysIndirect(exec, vbo_exec_MultiDrawArraysIndirect);
SET_MultiDrawElementsIndirect(exec, vbo_exec_MultiDrawElementsIndirect);
}