[Mesa-dev] commit 0a1479c829 breaks glsl-fs-lots-of-tex.shader_test on nv50/nvc0
Hi Marek, I won't pretend to understand what's going on, but I just bisected a failure on tests/shaders/glsl-fs-lots-of-tex.shader_test in piglit between 9.1 and HEAD, and it landed on your commit. It's approximately the simplest shader known to man (esp at HEAD when all the TEX instructions are gone due to CSE), so I'm guessing there's some edge condition in the copying logic triggered by it. Would be good to check if the same failure happens on radeon, although it works fine with llvmpipe. Assuming that nouveau is the only broken thing, any suggestions of what to look for? Thanks, -ilia 0a1479c829ed34a65e60c6619a8164e1b079aaee is the first bad commit commit 0a1479c829ed34a65e60c6619a8164e1b079aaee Author: Marek Olsak mar...@gmail.com Date: Thu Feb 14 01:03:55 2013 +0100 st/mesa: implement blit-based TexImage and TexSubImage A temporary texture is created such that it matches the format and type combination and pixels are copied to it using memcpy. Then the blit is used to copy the temporary texture to the texture image being modified by TexImage or TexSubImage. The blit takes care of the format and type conversion and swizzling. The result is a very fast texture upload involving as little CPU as possible. This improves performance in apps which upload textures during rendering. An example is the Wine OpenGL backend for DirectDraw, which I used to test the game StarCraft. Profiling had shown that TexSubImage was taking 50% of CPU time without this patch, which was the main motivation for this work, and now TexSubImage only takes 14% of CPU time. I had to underclock my CPU to see any difference in the game and this patch does make the game a lot faster if the CPU is slow (or using the powersave cpufreq profile). Reviewed-by: Brian Paul bri...@vmware.com ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 4/7] radeonsi: handle NULL colorbuffers correctly
On Thu, Jan 9, 2014 at 3:51 AM, Michel Dänzer mic...@daenzer.net wrote: On Mit, 2014-01-08 at 18:23 +0100, Marek Olšák wrote: diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c index 3666a11..ba73401 100644 --- a/src/gallium/drivers/radeonsi/si_state.c +++ b/src/gallium/drivers/radeonsi/si_state.c [...] @@ -2136,16 +2143,11 @@ static void si_set_framebuffer_state(struct pipe_context *ctx, [...] si_set_msaa_state(rctx, pm4, nr_samples); rctx-fb_log_samples = util_logbase2(nr_samples); - rctx-fb_cb0_is_integer = state-nr_cbufs + rctx-fb_cb0_is_integer = state-nr_cbufs state-cbufs[0] util_format_is_pure_integer(state-cbufs[0]-format); Should this check the first non-NULL cbuf now instead of always cbufs[0]? fb_cb0_is_integer only affects alpha-to-one and alpha-to-coverage, which only use the first shader color output. Setting fb_cb0_is_integer=FALSE means that both can be enabled. The types of other colorbuffers don't matter. Marek ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [Bug 70410] egl-static/Makefile: linking fails with llvm = 3.4
https://bugs.freedesktop.org/show_bug.cgi?id=70410 --- Comment #14 from Aaron Watry awa...@gmail.com --- Created attachment 91751 -- https://bugs.freedesktop.org/attachment.cgi?id=91751action=edit llvm-config patch to place system-libs on a single line Patch modifies llvm-config to print --system-libs on a single line. If the user requests 'llvm-config --libs --system-libs', then it still puts it on a single line, but orders the system libraries to come at the end. If you request --libs, then you just get libs. If you request --system-libs, then you just get system libraries that llvm links against. This way we just have to modify the mesa build to call 'llvm-config --libs --system-libs' anywhere needed, instead of doing some sed fiddling to the output and hoping we get it right. -- You are receiving this mail because: You are the assignee for the bug. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [Bug 71543] [mesa] Source-based games segfault
https://bugs.freedesktop.org/show_bug.cgi?id=71543 Johannes Hirte johannes.hi...@datenkhaos.de changed: What|Removed |Added CC||johannes.hirte@datenkhaos.d ||e -- You are receiving this mail because: You are the assignee for the bug. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] GPU lockup CP stall when calling clBuildProgram on Cayman
Hi, I am using kernel 3.12.6-gentoo, Mesa 10.0.1 and once every two calls to clBuildProgram, the GPU goes to reset after 10 seconds. This also happens on Debian unstable with Mesa 9.2. First hello_world works, the next one hangs, third works, and so on. Despite this hang on this particular OpenCL call, every thing is just fine. I tried to comment out DMA flushing code in r600/r600_hw_context.c, but this issue does not look the one that what was discovered on R600 HW. After the hang, opencl_examples/hello_world returns the correct value (when the machine does not hang completely which happens sometimes). Same behaviour for get-global-id test program. Here is my config logs: lscpi: 01:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Cayman PRO [Radeon HD 6950] dmesg: [ 826.250105] radeon :01:00.0: GPU lockup CP stall for more than 1msec [ 826.250110] radeon :01:00.0: GPU lockup (waiting for 0x37bc last fence id 0x37ba) [ 826.250118] [drm] Disabling audio 0 support [ 826.257466] radeon :01:00.0: Saved 111 dwords of commands on ring 0. [ 826.257496] radeon :01:00.0: GPU softreset: 0x0008 [ 826.257498] radeon :01:00.0: GRBM_STATUS = 0xB0001828 [ 826.257500] radeon :01:00.0: GRBM_STATUS_SE0 = 0x0003 [ 826.257502] radeon :01:00.0: GRBM_STATUS_SE1 = 0x0003 [ 826.257504] radeon :01:00.0: SRBM_STATUS = 0x20C0 [ 826.257526] radeon :01:00.0: SRBM_STATUS2 = 0x [ 826.257528] radeon :01:00.0: R_008674_CP_STALLED_STAT1 = 0x [ 826.257529] radeon :01:00.0: R_008678_CP_STALLED_STAT2 = 0x4000 [ 826.257531] radeon :01:00.0: R_00867C_CP_BUSY_STAT = 0x00010006 [ 826.257533] radeon :01:00.0: R_008680_CP_STAT = 0x80228647 [ 826.257535] radeon :01:00.0: R_00D034_DMA_STATUS_REG = 0x44C83D57 [ 826.257537] radeon :01:00.0: R_00D834_DMA_STATUS_REG = 0x44C83D57 [ 826.257539] radeon :01:00.0: VM_CONTEXT0_PROTECTION_FAULT_ADDR 0x [ 826.257541] radeon :01:00.0: VM_CONTEXT0_PROTECTION_FAULT_STATUS 0x [ 826.257542] radeon :01:00.0: VM_CONTEXT1_PROTECTION_FAULT_ADDR 0x [ 826.257544] radeon :01:00.0: VM_CONTEXT1_PROTECTION_FAULT_STATUS 0x [ 826.264350] radeon :01:00.0: GRBM_SOFT_RESET=0x4001 [ 826.264403] radeon :01:00.0: SRBM_SOFT_RESET=0x0100 [ 826.265558] radeon :01:00.0: GRBM_STATUS = 0x1828 [ 826.265560] radeon :01:00.0: GRBM_STATUS_SE0 = 0x0003 [ 826.265561] radeon :01:00.0: GRBM_STATUS_SE1 = 0x0003 [ 826.265563] radeon :01:00.0: SRBM_STATUS = 0x20C0 [ 826.265585] radeon :01:00.0: SRBM_STATUS2 = 0x [ 826.265587] radeon :01:00.0: R_008674_CP_STALLED_STAT1 = 0x [ 826.265589] radeon :01:00.0: R_008678_CP_STALLED_STAT2 = 0x [ 826.265590] radeon :01:00.0: R_00867C_CP_BUSY_STAT = 0x [ 826.265592] radeon :01:00.0: R_008680_CP_STAT = 0x [ 826.265594] radeon :01:00.0: R_00D034_DMA_STATUS_REG = 0x44C83D57 [ 826.265596] radeon :01:00.0: R_00D834_DMA_STATUS_REG = 0x44C83D57 [ 826.265623] radeon :01:00.0: GPU reset succeeded, trying to resume [ 826.283559] [drm] PCIE gen 2 link speeds already enabled [ 826.285981] [drm] PCIE GART of 1024M enabled (table at 0x00273000). [ 826.286049] radeon :01:00.0: WB enabled [ 826.286051] radeon :01:00.0: fence driver on ring 0 use gpu addr 0x8c00 and cpu addr 0x8800cbaa3c00 .. On hello_world.c program hangs every two calls at line: error = clBuildProgram(program, 1, /* Number of devices */ device_id, NULL, /* options */ NULL, /* callback function when compile is complete */ NULL); /* user data for callback */ Thanks for your help, Regards ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] OpenCL Clang/Clover Offline Compilation issue
I am not sure if this is the appropriate list on which to ask this question, if not hopefully someone can suggest an alternative. Under Linux, I am attempting to perform an offline compile of an OpenCL kernel example using Clang, and then load that binary using the clCreateProgramWithBinary() function. Unfortunately, while clover is loading the binary, I end up getting a segmentation fault: Program received signal SIGSEGV, Segmentation fault. proc (v=..., is=...) at core/module.cpp:50 50T x; I have pasted the source code I am using below, for both the kernel and the host code. I am compiling with the following commands: clang -target r600-unknown-unknown -x cl -S -emit-llvm -mcpu=r600 kernel.cl -o kernel.clbin clang -g -L/usr/local/lib -lOpenCL offline_host.c -o offline_host I have LLVM/Clang 3.4RC3 installed and Mesa 10.0.1. If anyone has suggestions, or can point me to the appropriate mailing list or documentation, I'd appreciate it. Thanks! -Al Source code for kernel.cl __kernel void vecAdd(__global float* a) { int gid = get_global_id(0); a[gid] += a[gid]; } Source code for offline_host.c == #include stdio.h #include stdlib.h #ifdef __APPLE__ #include OpenCL/opencl.h #else #include CL/cl.h #endif #define MEM_SIZE (128) #define MAX_BINARY_SIZE (0x10) int main() { cl_platform_id platform_id = NULL; cl_device_id device_id = NULL; cl_context context = NULL; cl_command_queue command_queue = NULL; cl_mem memobj = NULL; cl_program program = NULL; cl_kernel kernel = NULL; cl_uint ret_num_devices; cl_uint ret_num_platforms; cl_int ret; float mem[MEM_SIZE]; FILE *fp; char fileName[] = kernel.clbin; size_t binary_size; char *binary_buf; cl_int binary_status; cl_int i; /* Load kernel binary */ fp = fopen(fileName, r); if (!fp) { fprintf(stderr, Failed to load kernel.\n); exit(1); } binary_buf = (char *)malloc(MAX_BINARY_SIZE); binary_size = fread(binary_buf, 1, MAX_BINARY_SIZE, fp); fclose(fp); /* Initialize input data */ for (i = 0; i MEM_SIZE; i++) { mem[i] = i; } /* Get platform/device information */ ret = clGetPlatformIDs(1, platform_id, ret_num_platforms); ret = clGetDeviceIDs(platform_id, CL_DEVICE_TYPE_GPU, 1, device_id, ret_num_devices); /* Create OpenCL context*/ context = clCreateContext(NULL, 1, device_id, NULL, NULL, ret); /* Create command queue */ command_queue = clCreateCommandQueue(context, device_id, 0, ret); /* Create memory buffer */ memobj = clCreateBuffer(context, CL_MEM_READ_WRITE, MEM_SIZE * sizeof(float), NULL, ret); /* Transfer data over to the memory buffer */ ret = clEnqueueWriteBuffer(command_queue, memobj, CL_TRUE, 0, MEM_SIZE * sizeof(float), mem, 0, NULL, NULL); /* Create kernel program from the kernel binary */ program = clCreateProgramWithBinary(context, 1, device_id, (const size_t *)binary_size, (const unsigned char **)binary_buf, binary_status, ret); /* Create OpenCL kernel */ kernel = clCreateKernel(program, vecAdd, ret); printf(err:%d\n, ret); /* Set OpenCL kernel arguments */ ret = clSetKernelArg(kernel, 0, sizeof(cl_mem), (void *)memobj); size_t global_work_size[3] = {MEM_SIZE, 0, 0}; size_t local_work_size[3] = {MEM_SIZE, 0, 0}; /* Execute OpenCL kernel */ ret = clEnqueueNDRangeKernel(command_queue, kernel, 1, NULL, global_work_size, local_work_size, 0, NULL, NULL); /* Copy result from the memory buffer */ ret = clEnqueueReadBuffer(command_queue, memobj, CL_TRUE, 0, MEM_SIZE * sizeof(float), mem, 0, NULL, NULL); /* Display results */ for (i=0; i MEM_SIZE; i++) { printf(mem[%d] : $f\n, i, mem[i]); } /* Finalization */ ret = clFlush(command_queue); ret = clFinish(command_queue); ret = clReleaseKernel(kernel); ret = clReleaseProgram(program); ret = clReleaseMemObject(memobj); ret = clReleaseCommandQueue(command_queue); ret = clReleaseContext(context); free(binary_buf); return 0; } Al Dorrington Software Engineer Sr Lockheed Martin, Mission Systems and Training albert.dorring...@lmco.commailto:albert.dorring...@lmco.com / 607-751-4859 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [Bug 70410] egl-static/Makefile: linking fails with llvm = 3.4
https://bugs.freedesktop.org/show_bug.cgi?id=70410 --- Comment #15 from Krzysztof A. Sobiecki sob...@gmail.com --- Created attachment 91763 -- https://bugs.freedesktop.org/attachment.cgi?id=91763action=edit --system-libs patch without newline hack Hack free version of patch -- You are receiving this mail because: You are the assignee for the bug. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [Bug 70410] egl-static/Makefile: linking fails with llvm = 3.4
https://bugs.freedesktop.org/show_bug.cgi?id=70410 Krzysztof A. Sobiecki sob...@gmail.com changed: What|Removed |Added Attachment #91763|0 |1 is obsolete|| --- Comment #16 from Krzysztof A. Sobiecki sob...@gmail.com --- Created attachment 91764 -- https://bugs.freedesktop.org/attachment.cgi?id=91764action=edit --system-libs patch without newline hack A cleaner version -- You are receiving this mail because: You are the assignee for the bug. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] mesa: add missing SNORM formats in _mesa_base_fbo_format()
- Original Message - We weren't handling the LUMINANCE_SNORM, LUMINANCE_ALPHA_SNORM and INTENSITY_SNORM cases. Note that adding these cases here does not require a driver to support rendering to these surface types. If the driver can't do it we'll report an incomplete framebuffer. NVIDIA doesn't support GL_EXT_texture_snorm but their driver accepts these formats in glRenderBufferStorage(). --- src/mesa/main/fbobject.c | 16 1 file changed, 16 insertions(+) diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index 2892784..d846808 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -1504,6 +1504,22 @@ _mesa_base_fbo_format(struct gl_context *ctx, GLenum internalFormat) return ctx-API == API_OPENGL_COMPAT ctx-Extensions.EXT_texture_snorm ctx-Extensions.ARB_framebuffer_object ? GL_ALPHA : 0; + case GL_LUMINANCE_SNORM: + case GL_LUMINANCE8_SNORM: + case GL_LUMINANCE16_SNORM: + return _mesa_is_desktop_gl(ctx) ctx-Extensions.EXT_texture_snorm + ? GL_LUMINANCE : 0; + case GL_LUMINANCE_ALPHA_SNORM: + case GL_LUMINANCE8_ALPHA8_SNORM: + case GL_LUMINANCE16_ALPHA16_SNORM: + return _mesa_is_desktop_gl(ctx) ctx-Extensions.EXT_texture_snorm + ? GL_LUMINANCE_ALPHA : 0; + case GL_INTENSITY_SNORM: + case GL_INTENSITY8_SNORM: + case GL_INTENSITY16_SNORM: + return _mesa_is_desktop_gl(ctx) ctx-Extensions.EXT_texture_snorm + ? GL_INTENSITY : 0; + case GL_R16F: case GL_R32F: return ((_mesa_is_desktop_gl(ctx) -- 1.7.10.4 Reviewed-by: Jose Fonseca jfons...@vmware.com ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 5/5] mesa: Use functions to convert gl_shader_stage to PROGRAM enum or pipe target.
On 8 January 2014 12:21, Emil Velikov emil.l.veli...@gmail.com wrote: On 08/01/14 19:20, Paul Berry wrote: diff --git a/src/mesa/program/program.h b/src/mesa/program/program.h index 4015b4c..648233c 100644 --- a/src/mesa/program/program.h +++ b/src/mesa/program/program.h @@ -207,6 +207,24 @@ _mesa_program_enum_to_shader_stage(GLenum v) } } + +static inline GLenum +_mesa_shader_stage_to_program(gl_shader_stage stage) +{ + switch (stage) { + case MESA_SHADER_VERTEX: + return GL_VERTEX_PROGRAM_ARB; + case MESA_SHADER_FRAGMENT: + return GL_FRAGMENT_PROGRAM_ARB; + case MESA_SHADER_GEOMETRY: + return GL_GEOMETRY_PROGRAM_NV; + } + + ASSERT(0); Hi Paul Can you use a normal assert that prints a somewhat informative message - similar to what you did in shader_stage_to_ptarget()? Thanks Emil Sure, no problem. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/4] MSVC 2013: Preliminary support for MSVC_VERSION=12.0
Patches 2 3 are Reviewed-by: Ian Romanick ian.d.roman...@intel.com I don't know anything about the MSVC build system, so I can't really comment about patch 1. On 01/07/2014 02:38 PM, Thomas Sondergaard wrote: --- common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common.py b/common.py index 1d618e6..22c1725 100644 --- a/common.py +++ b/common.py @@ -100,4 +100,4 @@ def AddOptions(opts): opts.Add(BoolOption('quiet', 'DEPRECATED: profile build', 'yes')) opts.Add(BoolOption('texture_float', 'enable floating-point textures and renderbuffers', 'no')) if host_platform == 'windows': - opts.Add(EnumOption('MSVC_VERSION', 'MS Visual C++ version', None, allowed_values=('7.1', '8.0', '9.0', '10.0', '11.0'))) + opts.Add(EnumOption('MSVC_VERSION', 'MS Visual C++ version', None, allowed_values=('7.1', '8.0', '9.0', '10.0', '11.0', '12.0'))) ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 4/4] MSVC2013: Namespace qualify fma to override ambiguity with fma from math.h
On 01/07/2014 02:38 PM, Thomas Sondergaard wrote: MSVC 2013 version of math.h includes an fma() function. --- src/glsl/builtin_functions.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/glsl/builtin_functions.cpp b/src/glsl/builtin_functions.cpp index 10127f3..b3e407a 100644 --- a/src/glsl/builtin_functions.cpp +++ b/src/glsl/builtin_functions.cpp @@ -3936,7 +3936,7 @@ builtin_builder::_fma(const glsl_type *type) ir_variable *c = in_var(type, c); MAKE_SIG(type, gpu_shader5, 3, a, b, c); - body.emit(ret(fma(a, b, c))); + body.emit(ret(ir_builder::fma(a, b, c))); Like Ken, I'm not very happy about this, and I'm hoping there's a better way. Since we don't use namespace qualifiers for any of the other ir_builder code, issues like this will continue to creep in. :( return sig; } ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 5/5] mesa: Use functions to convert gl_shader_stage to PROGRAM enum or pipe target.
On 01/08/2014 11:20 AM, Paul Berry wrote: Suggested-by: Brian Paul bri...@vmware.com --- src/mesa/program/ir_to_mesa.cpp| 17 + src/mesa/program/program.h | 18 ++ src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 40 +++--- 3 files changed, 39 insertions(+), 36 deletions(-) diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index 7988248..f6c229c 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -2799,26 +2799,11 @@ get_mesa_program(struct gl_context *ctx, ir_instruction **mesa_instruction_annotation; int i; struct gl_program *prog; - GLenum target; + GLenum target = _mesa_shader_stage_to_program(shader-Stage); I think some of these can be const. const char *target_string = _mesa_shader_stage_to_string(shader-Stage); struct gl_shader_compiler_options *options = ctx-ShaderCompilerOptions[shader-Stage]; - switch (shader-Stage) { - case MESA_SHADER_VERTEX: - target = GL_VERTEX_PROGRAM_ARB; - break; - case MESA_SHADER_FRAGMENT: - target = GL_FRAGMENT_PROGRAM_ARB; - break; - case MESA_SHADER_GEOMETRY: - target = GL_GEOMETRY_PROGRAM_NV; - break; - default: - assert(!should not be reached); - return NULL; - } - validate_ir_tree(shader-ir); prog = ctx-Driver.NewProgram(ctx, target, shader_program-Name); diff --git a/src/mesa/program/program.h b/src/mesa/program/program.h index 4015b4c..648233c 100644 --- a/src/mesa/program/program.h +++ b/src/mesa/program/program.h @@ -207,6 +207,24 @@ _mesa_program_enum_to_shader_stage(GLenum v) } } + +static inline GLenum +_mesa_shader_stage_to_program(gl_shader_stage stage) +{ + switch (stage) { + case MESA_SHADER_VERTEX: + return GL_VERTEX_PROGRAM_ARB; + case MESA_SHADER_FRAGMENT: + return GL_FRAGMENT_PROGRAM_ARB; + case MESA_SHADER_GEOMETRY: + return GL_GEOMETRY_PROGRAM_NV; + } + + ASSERT(0); + return GL_VERTEX_PROGRAM_ARB; +} + + static inline GLenum _mesa_program_index_to_target(GLuint i) { diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index 4b6fd2d..73c39eb 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -5023,6 +5023,24 @@ out: } /* - End TGSI code -- */ + +static unsigned +shader_stage_to_ptarget(gl_shader_stage stage) +{ + switch (stage) { + case MESA_SHADER_VERTEX: + return PIPE_SHADER_VERTEX; + case MESA_SHADER_FRAGMENT: + return PIPE_SHADER_FRAGMENT; + case MESA_SHADER_GEOMETRY: + return PIPE_SHADER_GEOMETRY; + } + + assert(!should not be reached); + return PIPE_SHADER_VERTEX; +} + + /** * Convert a shader's GLSL IR into a Mesa gl_program, although without * generating Mesa IR. @@ -5034,30 +5052,12 @@ get_mesa_program(struct gl_context *ctx, { glsl_to_tgsi_visitor* v; struct gl_program *prog; - GLenum target; + GLenum target = _mesa_shader_stage_to_program(shader-Stage); bool progress; struct gl_shader_compiler_options *options = ctx-ShaderCompilerOptions[_mesa_shader_enum_to_shader_stage(shader-Type)]; struct pipe_screen *pscreen = ctx-st-pipe-screen; - unsigned ptarget; - - switch (shader-Type) { - case GL_VERTEX_SHADER: - target = GL_VERTEX_PROGRAM_ARB; - ptarget = PIPE_SHADER_VERTEX; - break; - case GL_FRAGMENT_SHADER: - target = GL_FRAGMENT_PROGRAM_ARB; - ptarget = PIPE_SHADER_FRAGMENT; - break; - case GL_GEOMETRY_SHADER: - target = GL_GEOMETRY_PROGRAM_NV; - ptarget = PIPE_SHADER_GEOMETRY; - break; - default: - assert(!should not be reached); - return NULL; - } + unsigned ptarget = shader_stage_to_ptarget(shader-Stage); validate_ir_tree(shader-ir); ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] st/mesa: fix breakage from gl_constant::Program[] change
--- src/mesa/state_tracker/st_extensions.c | 26 +- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c index 5e4a3b3..c17601a 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -155,15 +155,15 @@ void st_init_limits(struct st_context *st) switch (sh) { case PIPE_SHADER_FRAGMENT: - pc = c-FragmentProgram; + pc = c-Program[MESA_SHADER_FRAGMENT]; options = st-ctx-ShaderCompilerOptions[MESA_SHADER_FRAGMENT]; break; case PIPE_SHADER_VERTEX: - pc = c-VertexProgram; + pc = c-Program[MESA_SHADER_VERTEX]; options = st-ctx-ShaderCompilerOptions[MESA_SHADER_VERTEX]; break; case PIPE_SHADER_GEOMETRY: - pc = c-GeometryProgram; + pc = c-Program[MESA_SHADER_GEOMETRY]; options = st-ctx-ShaderCompilerOptions[MESA_SHADER_GEOMETRY]; break; default: @@ -245,21 +245,21 @@ void st_init_limits(struct st_context *st) /* This depends on program constants. */ c-MaxTextureCoordUnits - = _min(c-FragmentProgram.MaxTextureImageUnits, MAX_TEXTURE_COORD_UNITS); + = _min(c-Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits, MAX_TEXTURE_COORD_UNITS); - c-MaxTextureUnits = _min(c-FragmentProgram.MaxTextureImageUnits, c-MaxTextureCoordUnits); + c-MaxTextureUnits = _min(c-Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits, c-MaxTextureCoordUnits); - c-VertexProgram.MaxAttribs = MIN2(c-VertexProgram.MaxAttribs, 16); + c-Program[MESA_SHADER_VERTEX].MaxAttribs = MIN2(c-Program[MESA_SHADER_VERTEX].MaxAttribs, 16); /* PIPE_SHADER_CAP_MAX_INPUTS for the FS specifies the maximum number * of inputs. It's always 2 colors + N generic inputs. */ c-MaxVarying = screen-get_shader_param(screen, PIPE_SHADER_FRAGMENT, PIPE_SHADER_CAP_MAX_INPUTS); c-MaxVarying = MIN2(c-MaxVarying, MAX_VARYING); - c-FragmentProgram.MaxInputComponents = c-MaxVarying * 4; - c-VertexProgram.MaxOutputComponents = c-MaxVarying * 4; - c-GeometryProgram.MaxInputComponents = c-MaxVarying * 4; - c-GeometryProgram.MaxOutputComponents = c-MaxVarying * 4; + c-Program[MESA_SHADER_FRAGMENT].MaxInputComponents = c-MaxVarying * 4; + c-Program[MESA_SHADER_VERTEX].MaxOutputComponents = c-MaxVarying * 4; + c-Program[MESA_SHADER_GEOMETRY].MaxInputComponents = c-MaxVarying * 4; + c-Program[MESA_SHADER_GEOMETRY].MaxOutputComponents = c-MaxVarying * 4; c-MinProgramTexelOffset = screen-get_param(screen, PIPE_CAP_MIN_TEXEL_OFFSET); c-MaxProgramTexelOffset = screen-get_param(screen, PIPE_CAP_MAX_TEXEL_OFFSET); @@ -284,9 +284,9 @@ void st_init_limits(struct st_context *st) c-UniformBufferOffsetAlignment = screen-get_param(screen, PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT); c-MaxCombinedUniformBlocks = c-MaxUniformBufferBindings = - c-VertexProgram.MaxUniformBlocks + - c-GeometryProgram.MaxUniformBlocks + - c-FragmentProgram.MaxUniformBlocks; + c-Program[MESA_SHADER_VERTEX].MaxUniformBlocks + + c-Program[MESA_SHADER_GEOMETRY].MaxUniformBlocks + + c-Program[MESA_SHADER_FRAGMENT].MaxUniformBlocks; assert(c-MaxCombinedUniformBlocks = MAX_COMBINED_UNIFORM_BUFFERS); } } -- 1.7.10.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 3/5] glsl: Index into ctx-Const.Program[] rather than using ad-hoc code.
On 01/08/2014 11:20 AM, Paul Berry wrote: --- src/glsl/ast_to_hir.cpp| 13 + src/glsl/link_atomics.cpp | 16 ++-- src/glsl/link_varyings.cpp | 32 ++-- src/glsl/linker.cpp| 43 --- 4 files changed, 17 insertions(+), 87 deletions(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index 1ac6047..ef8e699 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -1983,18 +1983,7 @@ validate_binding_qualifier(struct _mesa_glsl_parse_state *state, * with an array of size N, all elements of the array from binding * through binding + N - 1 must be within this range. */ - unsigned limit = 0; - switch (state-stage) { - case MESA_SHADER_VERTEX: - limit = ctx-Const.Program[MESA_SHADER_VERTEX].MaxTextureImageUnits; - break; - case MESA_SHADER_GEOMETRY: - limit = ctx-Const.Program[MESA_SHADER_GEOMETRY].MaxTextureImageUnits; - break; - case MESA_SHADER_FRAGMENT: - limit = ctx-Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits; - break; - } + unsigned limit = ctx-Const.Program[state-stage].MaxTextureImageUnits; Now this can be const. :) I think a bunch of the others can be too. if (max_index = limit) { _mesa_glsl_error(loc, state, layout(binding = %d) for %d samplers diff --git a/src/glsl/link_atomics.cpp b/src/glsl/link_atomics.cpp index 7f4ddaf..db9c539 100644 --- a/src/glsl/link_atomics.cpp +++ b/src/glsl/link_atomics.cpp @@ -214,18 +214,6 @@ void link_check_atomic_counter_resources(struct gl_context *ctx, struct gl_shader_program *prog) { - const unsigned max_atomic_counters[] = { - ctx-Const.Program[MESA_SHADER_VERTEX].MaxAtomicCounters, - ctx-Const.Program[MESA_SHADER_GEOMETRY].MaxAtomicCounters, - ctx-Const.Program[MESA_SHADER_FRAGMENT].MaxAtomicCounters - }; - STATIC_ASSERT(Elements(max_atomic_counters) == MESA_SHADER_STAGES); - const unsigned max_atomic_buffers[] = { - ctx-Const.Program[MESA_SHADER_VERTEX].MaxAtomicBuffers, - ctx-Const.Program[MESA_SHADER_GEOMETRY].MaxAtomicBuffers, - ctx-Const.Program[MESA_SHADER_FRAGMENT].MaxAtomicBuffers - }; - STATIC_ASSERT(Elements(max_atomic_buffers) == MESA_SHADER_STAGES); unsigned num_buffers; active_atomic_buffer *const abs = find_active_atomic_counters(ctx, prog, num_buffers); @@ -257,11 +245,11 @@ link_check_atomic_counter_resources(struct gl_context *ctx, /* Check that they are within the supported limits. */ for (unsigned i = 0; i MESA_SHADER_STAGES; i++) { - if (atomic_counters[i] max_atomic_counters[i]) + if (atomic_counters[i] ctx-Const.Program[i].MaxAtomicCounters) linker_error(prog, Too many %s shader atomic counters, _mesa_shader_stage_to_string(i)); - if (atomic_buffers[i] max_atomic_buffers[i]) + if (atomic_buffers[i] ctx-Const.Program[i].MaxAtomicBuffers) linker_error(prog, Too many %s shader atomic counter buffers, _mesa_shader_stage_to_string(i)); } diff --git a/src/glsl/link_varyings.cpp b/src/glsl/link_varyings.cpp index 6672b87..c925c00 100644 --- a/src/glsl/link_varyings.cpp +++ b/src/glsl/link_varyings.cpp @@ -1249,19 +1249,9 @@ check_against_output_limit(struct gl_context *ctx, } } - unsigned max_output_components; - switch (producer-Stage) { - case MESA_SHADER_VERTEX: - max_output_components = ctx-Const.Program[MESA_SHADER_VERTEX].MaxOutputComponents; - break; - case MESA_SHADER_GEOMETRY: - max_output_components = ctx-Const.Program[MESA_SHADER_GEOMETRY].MaxOutputComponents; - break; - case MESA_SHADER_FRAGMENT: - default: - assert(!Should not get here.); - return false; - } + assert(producer-Stage != MESA_SHADER_FRAGMENT); + unsigned max_output_components = + ctx-Const.Program[producer-Stage].MaxOutputComponents; const unsigned output_components = output_vectors * 4; if (output_components max_output_components) { @@ -1298,19 +1288,9 @@ check_against_input_limit(struct gl_context *ctx, } } - unsigned max_input_components; - switch (consumer-Stage) { - case MESA_SHADER_GEOMETRY: - max_input_components = ctx-Const.Program[MESA_SHADER_GEOMETRY].MaxInputComponents; - break; - case MESA_SHADER_FRAGMENT: - max_input_components = ctx-Const.Program[MESA_SHADER_FRAGMENT].MaxInputComponents; - break; - case MESA_SHADER_VERTEX: - default: - assert(!Should not get here.); - return false; - } + assert(consumer-Stage != MESA_SHADER_VERTEX); + unsigned max_input_components = + ctx-Const.Program[consumer-Stage].MaxInputComponents;
Re: [Mesa-dev] [PATCH 2/3] i965/gen6/blorp: Set need_workaround_flush at top of blorp (v2)
On Wed, Jan 08, 2014 at 07:59:38AM -0800, Paul Berry wrote: On 7 January 2014 16:58, Chad Versace chad.vers...@linux.intel.com wrote: Unconditionally set brw-need_workaround_flush at the top of gen6 blorp state emission. The art of emitting workaround flushes on Sandybridge is mysterious and not fully understood. Ken and I believe that intel_emit_post_sync_nonzero_flush() may be required when switching from regular drawing to blorp. This is an extra safety measure to prevent undiscovered difficult-to-diagnose gpu hangs. I verified that on ChromeOS, pre-patch, need_workaround_flush was not set at the top of blorp, as Paul expected. To verify, I inserted the following debug code at the top of gen6_blorp_exec(), restarted the ui, and inspected the logs in /var/log/ui. The abort gets triggered so early that the browser never appears on the display. static void gen6_blorp_exec(...) { if (!brw-need_workaround_flush) { fprintf(stderr, chadv: %s:%d\n, __FILE__, __LINE__); abort(); } ... } v2: Explain how I determined that need_workaround_flush wasn't getting set when expected. CC: Kenneth Graunke kenn...@whitecape.org CC: Paul Berry stereotype...@gmail.com CC: Stéphane Marchesin marc...@chromium.org Signed-off-by: Chad Versace chad.vers...@linux.intel.com --- src/mesa/drivers/dri/i965/gen6_blorp.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) Ok, I dug a little further and figured out what was wrong with my previous reasoning. It turns out that we call intel_batchbuffer_emit_mi_flush() at the top of brw_blorp_exec(). intel_batchbuffer_emit_mi_flush() in turn calls intel_emit_post_sync_nonzero_flush() before emitting its pipe control. As a result, brw-need_workaround_flush is always false on entry to gen6_blorp_exec (). By resetting brw-need_workaround_flush to true at the top of gen6_blorp_exec(), we ensure that the pipe control emitted by intel_batchbuffer_emit_mi_flush() is also followed by a post-sync nonzero flush. Now that I understand what's going on, I'm fine with the patch as is. If you want to copy anything from my paragraph above into the commit message, feel free to do so, but whether you do or not, the series is: Reviewed-by: Paul Berry stereotype...@gmail.com The commit message is already quite verbose, so I'll leave it as-is. Thanks for the thorough review. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] /usr/lib/libglapi.la: No such file or directory
Hello, When I try to compile mesa-demos-8.1.0 I got this: $ ./configure --prefix=/usr $ make [...] Making all in src make[1]: Entering directory `/home/yugiohjcj/documents/downloads/software/mesa-demos-8.1.0/src' Making all in util make[2]: Entering directory `/home/yugiohjcj/documents/downloads/software/mesa-demos-8.1.0/src/util' CC readtex.lo CC showbuffer.lo CC shaderutil.lo CCLD libutil.la /bin/grep: /usr/lib/libglapi.la: No such file or directory /bin/sed: can't read /usr/lib/libglapi.la: No such file or directory libtool: link: `/usr/lib/libglapi.la' is not a valid libtool archive make[2]: *** [libutil.la] Error 1 make[2]: Leaving directory `/home/yugiohjcj/documents/downloads/software/mesa-demos-8.1.0/src/util' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/home/yugiohjcj/documents/downloads/software/mesa-demos-8.1.0/src' make: *** [all-recursive] Error 1 So, I see /usr/lib/libglapi.la is missing. I recompile MesaLib-8.0.4 like this: $ ./configure --prefix=/usr --sysconfdir=/etc --libdir=/usr/lib --mandir=/usr/man --docdir=/usr/doc/mesa-8.0.4 --with-dri-driverdir=/usr/lib/xorg/modules/dri --with-dri-drivers=i915,i965 --enable-shared-glapi $ make Then I install it. But the problem with mesa-demos-8.1.0 remains. The /usr/lib/libglapi.la file is not available. Do you have any idea how to resolve this problem ? Thank you. Best regards. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 16/42] i965/blorp: remove dependency to compression control state
On Fri, Dec 20, 2013 at 6:38 AM, Topi Pohjolainen topi.pohjolai...@intel.com wrote: Effectively only the mask control bit gets altered for the single addition in question and hence there is no real need to use a fresh state control level for it -- that is more useful when multiple intructions share the same mask and compression settings. This is a preparation step for removing the explicit compression control modifiers in the blit compiler. After this patch there are no nested state control levels making the constant nature of the compression settings more apparent. No regressions on IVB (piglit quick + unit tests). Signed-off-by: Topi Pohjolainen topi.pohjolai...@intel.com --- src/mesa/drivers/dri/i965/brw_blorp_blit.cpp | 5 + 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp index 112a307..4d62411 100644 --- a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp +++ b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp @@ -1407,10 +1407,7 @@ brw_blorp_blit_program::kill_if_outside_dst_rect() brw_CMP(func, null32, BRW_CONDITIONAL_L, Y, dst_y1); brw_set_predicate_control(func, BRW_PREDICATE_NONE); - brw_push_insn_state(func); - brw_set_mask_control(func, BRW_MASK_DISABLE); - brw_AND(func, g1, f0, g1); - brw_pop_insn_state(func); + brw_AND(func, g1, f0, g1)-header.mask_control = BRW_MASK_DISABLE; } Minor comment: I don't really love the function call and pointer dereference in one line. I'd rather see struct brw_instruction *inst = brw_AND(func, g1, f0, g1); inst-header.mask_control = BRW_MASK_DISABLE; ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] Mesa (master): mesa: replace ctx-Const.{Vertex, Fragment, Geomtery}Program with an array.
- Original Message - Module: Mesa Branch: master Commit: 84732a982c3eeaca2e2809532c8422dc5f7045c1 URL: https://urldefense.proofpoint.com/v1/url?u=http://cgit.freedesktop.org/mesa/mesa/commit/?id%3D84732a982c3eeaca2e2809532c8422dc5f7045c1k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0Ar=NMr9uy2iTjWVixC0wOcYCWEIYhfo80qKwRgdodpoDzA%3D%0Am=9DwPDHJaDAAyqfsxRgnePXLQ%2BaaGu%2FosJQ%2BFGBXIoPE%3D%0As=110fd0cac78061466f428820411e5aa2f2872e8e2ae99323974356f0544b8cfd Author: Paul Berry stereotype...@gmail.com Date: Wed Jan 8 10:00:28 2014 -0800 mesa: replace ctx-Const.{Vertex,Fragment,Geomtery}Program with an array. These are replaced with ctx-Const.Program[MESA_SHADER_{VERTEX,FRAGMENT,GEOMETRY}]. In patches to follow, this will allow us to replace a lot of ad-hoc logic with a variable index into the array. With the exception of the changes to mtypes.h, this patch was generated entirely by the command: find src -type f '(' -iname '*.c' -o -iname '*.cpp' -o -iname '*.py' \ -o -iname '*.y' ')' -print0 | xargs -0 sed -i \ -e 's/Const\.VertexProgram/Const.Program[MESA_SHADER_VERTEX]/g' \ -e 's/Const\.GeometryProgram/Const.Program[MESA_SHADER_GEOMETRY]/g' \ -e 's/Const\.FragmentProgram/Const.Program[MESA_SHADER_FRAGMENT]/g' Suggested-by: Brian Paul bri...@vmware.com Reviewed-by: Brian Paul bri...@vmware.com Reviewed-by: Kenneth Graunke kenn...@whitecape.org Something bad happened here. Jose - Forwarded Message - mesa-ubuntu64 - Build # 10674 - Failure: Log: [...truncated 290 lines...] Compiling src/mesa/state_tracker/st_extensions.c ... src/mesa/state_tracker/st_extensions.c: In function 'st_init_limits': src/mesa/state_tracker/st_extensions.c:158:17: error: 'struct gl_constants' has no member named 'FragmentProgram' src/mesa/state_tracker/st_extensions.c:162:17: error: 'struct gl_constants' has no member named 'VertexProgram' src/mesa/state_tracker/st_extensions.c:166:17: error: 'struct gl_constants' has no member named 'GeometryProgram' src/mesa/state_tracker/st_extensions.c:248:15: error: 'struct gl_constants' has no member named 'FragmentProgram' src/mesa/state_tracker/st_extensions.c:250:31: error: 'struct gl_constants' has no member named 'FragmentProgram' src/mesa/state_tracker/st_extensions.c:252:5: error: 'struct gl_constants' has no member named 'VertexProgram' src/mesa/state_tracker/st_extensions.c:252:34: error: 'struct gl_constants' has no member named 'VertexProgram' src/mesa/state_tracker/st_extensions.c:252:34: error: 'struct gl_constants' has no member named 'VertexProgram' src/mesa/state_tracker/st_extensions.c:259:5: error: 'struct gl_constants' has no member named 'FragmentProgram' src/mesa/state_tracker/st_extensions.c:260:5: error: 'struct gl_constants' has no member named 'VertexProgram' src/mesa/state_tracker/st_extensions.c:261:5: error: 'struct gl_constants' has no member named 'GeometryProgram' src/mesa/state_tracker/st_extensions.c:262:5: error: 'struct gl_constants' has no member named 'GeometryProgram' src/mesa/state_tracker/st_extensions.c:287:11: error: 'struct gl_constants' has no member named 'VertexProgram' src/mesa/state_tracker/st_extensions.c:288:11: error: 'struct gl_constants' has no member named 'GeometryProgram' src/mesa/state_tracker/st_extensions.c:289:11: error: 'struct gl_constants' has no member named 'FragmentProgram' scons: *** [build/linux-x86_64-checked/mesa/state_tracker/st_extensions.os] Error 1 scons: building terminated because of errors. Build step 'Invoke SCons script' marked build as failure [WARNINGS] Skipping publisher since build result is FAILURE Archiving artifacts Email was triggered for: Failure Sending email for trigger: Failure Changes: Changes for Build #10674 [stereotype441] mesa: replace ctx-Const.{Vertex,Fragment,Geomtery}Program with an array. [stereotype441] mesa: Index into ctx-Const.Program[] rather than using ad-hoc code. [stereotype441] glsl: Index into ctx-Const.Program[] rather than using ad-hoc code. [stereotype441] main: Change init_program_limits() to use gl_shader_stage. [stereotype441] mesa: Use functions to convert gl_shader_stage to PROGRAM enum or pipe target. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 3/5] glsl: Add parameter to .equals() to ignore an IR type.
On 01/08/2014 12:43 PM, Matt Turner wrote: Only implemented for ir_swizzles currently, but perhaps will be useful And ir_texture? for other IR types in the future. --- src/glsl/ir.h | 14 +-- src/glsl/ir_equals.cpp | 63 +++--- 2 files changed, 41 insertions(+), 36 deletions(-) diff --git a/src/glsl/ir.h b/src/glsl/ir.h index 780959b..9968fb5 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -148,7 +148,7 @@ public: * in particular. No support for other instruction types (assignments, * jumps, calls, etc.) is planned. */ - virtual bool equals(ir_instruction *ir); + virtual bool equals(ir_instruction *ir, enum ir_node_type ignore = ir_type_unset); protected: ir_instruction() @@ -1429,7 +1429,7 @@ public: return this; } - virtual bool equals(ir_instruction *ir); + virtual bool equals(ir_instruction *ir, enum ir_node_type ignore = ir_type_unset); virtual ir_expression *clone(void *mem_ctx, struct hash_table *ht) const; @@ -1765,7 +1765,7 @@ public: virtual ir_visitor_status accept(ir_hierarchical_visitor *); - virtual bool equals(ir_instruction *ir); + virtual bool equals(ir_instruction *ir, enum ir_node_type ignore = ir_type_unset); /** * Return a string representing the ir_texture_opcode. @@ -1871,7 +1871,7 @@ public: virtual ir_visitor_status accept(ir_hierarchical_visitor *); - virtual bool equals(ir_instruction *ir); + virtual bool equals(ir_instruction *ir, enum ir_node_type ignore = ir_type_unset); bool is_lvalue() const { @@ -1937,7 +1937,7 @@ public: return this; } - virtual bool equals(ir_instruction *ir); + virtual bool equals(ir_instruction *ir, enum ir_node_type ignore = ir_type_unset); /** * Get the variable that is ultimately referenced by an r-value @@ -1997,7 +1997,7 @@ public: return this; } - virtual bool equals(ir_instruction *ir); + virtual bool equals(ir_instruction *ir, enum ir_node_type ignore = ir_type_unset); /** * Get the variable that is ultimately referenced by an r-value @@ -2133,7 +2133,7 @@ public: virtual ir_visitor_status accept(ir_hierarchical_visitor *); - virtual bool equals(ir_instruction *ir); + virtual bool equals(ir_instruction *ir, enum ir_node_type ignore = ir_type_unset); /** * Get a particular component of a constant as a specific type diff --git a/src/glsl/ir_equals.cpp b/src/glsl/ir_equals.cpp index 7cfe1e6..fa7fc72 100644 --- a/src/glsl/ir_equals.cpp +++ b/src/glsl/ir_equals.cpp @@ -28,12 +28,12 @@ * can't access a's vtable in that case. */ static bool -possibly_null_equals(ir_instruction *a, ir_instruction *b) +possibly_null_equals(ir_instruction *a, ir_instruction *b, enum ir_node_type ignore) { if (!a || !b) return !a !b; - return a-equals(b); + return a-equals(b, ignore); } /** @@ -41,13 +41,13 @@ possibly_null_equals(ir_instruction *a, ir_instruction *b) * about. */ bool -ir_instruction::equals(ir_instruction *ir) +ir_instruction::equals(ir_instruction *ir, enum ir_node_type) { return false; } bool -ir_constant::equals(ir_instruction *ir) +ir_constant::equals(ir_instruction *ir, enum ir_node_type ignore) { const ir_constant *other = ir-as_constant(); if (!other) @@ -65,7 +65,7 @@ ir_constant::equals(ir_instruction *ir) } bool -ir_dereference_variable::equals(ir_instruction *ir) +ir_dereference_variable::equals(ir_instruction *ir, enum ir_node_type ignore) { const ir_dereference_variable *other = ir-as_dereference_variable(); if (!other) @@ -75,7 +75,7 @@ ir_dereference_variable::equals(ir_instruction *ir) } bool -ir_dereference_array::equals(ir_instruction *ir) +ir_dereference_array::equals(ir_instruction *ir, enum ir_node_type ignore) { const ir_dereference_array *other = ir-as_dereference_array(); if (!other) @@ -84,17 +84,17 @@ ir_dereference_array::equals(ir_instruction *ir) if (type != other-type) return false; - if (!array-equals(other-array)) + if (!array-equals(other-array, ignore)) return false; - if (!array_index-equals(other-array_index)) + if (!array_index-equals(other-array_index, ignore)) return false; return true; } bool -ir_swizzle::equals(ir_instruction *ir) +ir_swizzle::equals(ir_instruction *ir, enum ir_node_type ignore) { const ir_swizzle *other = ir-as_swizzle(); if (!other) @@ -103,18 +103,20 @@ ir_swizzle::equals(ir_instruction *ir) if (type != other-type) return false; - if (mask.x != other-mask.x || - mask.y != other-mask.y || - mask.z != other-mask.z || - mask.w != other-mask.w) { - return false; + if (ignore != ir_type_swizzle) { + if (mask.x !=
[Mesa-dev] [PATCH 7/7] c11: Make TIME_UTC a conditional macro.
From: José Fonseca jfons...@vmware.com Some system headers already define it, so this prevents conflict. --- include/c11/threads.h | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/c11/threads.h b/include/c11/threads.h index 678774c..4a4079d 100644 --- a/include/c11/threads.h +++ b/include/c11/threads.h @@ -10,6 +10,10 @@ #include time.h +#ifndef TIME_UTC +#define TIME_UTC 1 +#endif + #include c99_compat.h /* for `inline` */ /* types */ @@ -39,8 +43,6 @@ enum { thrd_nomem// out of memory }; -enum { TIME_UTC = 1 }; - /*-- functions --*/ #if defined(_WIN32) !defined(__CYGWIN__) -- 1.8.3.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/7] c11: Import threads.h emulation library.
From: José Fonseca jfons...@vmware.com Implementation is based of https://gist.github.com/2223710 with the following modifications: - inline implementatation - retain XP compatability - add temporary hack for static mutex initializers (as they are not part of the stack but still widely used internally). --- include/c11/threads.h | 56 + include/c11/threads_posix.h | 346 ++ include/c11/threads_win32.h | 588 3 files changed, 990 insertions(+) create mode 100644 include/c11/threads.h create mode 100644 include/c11/threads_posix.h create mode 100644 include/c11/threads_win32.h diff --git a/include/c11/threads.h b/include/c11/threads.h new file mode 100644 index 000..678774c --- /dev/null +++ b/include/c11/threads.h @@ -0,0 +1,56 @@ +/* + * C11 threads.h emulation library + * + * (C) Copyright yohhoy 2012. + * Distributed under the Boost Software License, Version 1.0. + * (See copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef EMULATED_THREADS_H_INCLUDED_ +#define EMULATED_THREADS_H_INCLUDED_ + +#include time.h + +#include c99_compat.h /* for `inline` */ + +/* types */ +typedef void (*tss_dtor_t)(void*); +typedef int (*thrd_start_t)(void*); + +struct xtime { +time_t sec; +long nsec; +}; +typedef struct xtime xtime; + + +/* enumeration constants */ +enum { +mtx_plain = 0, +mtx_try = 1, +mtx_timed = 2, +mtx_recursive = 4 +}; + +enum { +thrd_success = 0, // succeeded +thrd_timeout, // timeout +thrd_error, // failed +thrd_busy,// resource busy +thrd_nomem// out of memory +}; + +enum { TIME_UTC = 1 }; + +/*-- functions --*/ + +#if defined(_WIN32) !defined(__CYGWIN__) +#include threads_win32.h +#elif defined(__unix__) || defined(__unix) +#include threads_posix.h +#else +#error Not supported on this platform. +#endif + + + +#endif /* EMULATED_THREADS_H_INCLUDED_ */ diff --git a/include/c11/threads_posix.h b/include/c11/threads_posix.h new file mode 100644 index 000..463c93f --- /dev/null +++ b/include/c11/threads_posix.h @@ -0,0 +1,346 @@ +/* + * C11 threads.h emulation library + * + * (C) Copyright yohhoy 2012. + * Distributed under the Boost Software License, Version 1.0. + * (See copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#include stdlib.h +#include assert.h +#include limits.h +#include errno.h +#include unistd.h +#include sched.h +#include stdint.h /* for intptr_t */ + +/* +Configuration macro: + + EMULATED_THREADS_USE_NATIVE_TIMEDLOCK +Use pthread_mutex_timedlock() for `mtx_timedlock()' +Otherwise use mtx_trylock() + *busy loop* emulation. +*/ +#if !defined(__CYGWIN__) +#define EMULATED_THREADS_USE_NATIVE_TIMEDLOCK +#endif + + +#include pthread.h + +/* macros */ +#define ONCE_FLAG_INIT PTHREAD_ONCE_INIT +#ifdef INIT_ONCE_STATIC_INIT +#define TSS_DTOR_ITERATIONS PTHREAD_DESTRUCTOR_ITERATIONS +#else +#define TSS_DTOR_ITERATIONS 1 // assume TSS dtor MAY be called at least once. +#endif + +// FIXME: temporary non-standard hack to ease transition +#define _MTX_INITIALIZER_NP PTHREAD_MUTEX_INITIALIZER + +/* types */ +typedef pthread_cond_t cnd_t; +typedef pthread_t thrd_t; +typedef pthread_key_t tss_t; +typedef pthread_mutex_t mtx_t; +typedef pthread_once_t once_flag; + + +/* +Implementation limits: + - Conditionally emulation for mutex with timeout +(see EMULATED_THREADS_USE_NATIVE_TIMEDLOCK macro) +*/ +struct impl_thrd_param { +thrd_start_t func; +void *arg; +}; + +static inline void * +impl_thrd_routine(void *p) +{ +struct impl_thrd_param pack = *((struct impl_thrd_param *)p); +free(p); +return (void*)(intptr_t)pack.func(pack.arg); +} + + +/*--- 7.25.2 Initialization functions ---*/ +// 7.25.2.1 +static inline void +call_once(once_flag *flag, void (*func)(void)) +{ +pthread_once(flag, func); +} + + +/*- 7.25.3 Condition variable functions -*/ +// 7.25.3.1 +static inline int +cnd_broadcast(cnd_t *cond) +{ +if (!cond) return thrd_error; +pthread_cond_broadcast(cond); +return thrd_success; +} + +// 7.25.3.2 +static inline void +cnd_destroy(cnd_t *cond) +{ +assert(cond); +pthread_cond_destroy(cond); +} + +// 7.25.3.3 +static inline int +cnd_init(cnd_t *cond) +{ +if (!cond) return thrd_error; +pthread_cond_init(cond, NULL); +return thrd_success; +} + +// 7.25.3.4 +static inline int +cnd_signal(cnd_t *cond) +{ +if (!cond) return thrd_error; +pthread_cond_signal(cond); +return thrd_success; +} + +// 7.25.3.5 +static inline int +cnd_timedwait(cnd_t *cond, mtx_t *mtx, const xtime *xt) +{ +struct timespec abs_time; +int rt; +
[Mesa-dev] [PATCH 5/7] egl: Use C11 thread abstractions.
From: José Fonseca jfons...@vmware.com --- src/egl/main/eglmutex.h | 26 +++--- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/src/egl/main/eglmutex.h b/src/egl/main/eglmutex.h index 1349e9e..2ec965c 100644 --- a/src/egl/main/eglmutex.h +++ b/src/egl/main/eglmutex.h @@ -31,46 +31,34 @@ #include eglcompiler.h -#ifdef HAVE_PTHREAD -#include pthread.h +#include c11/threads.h -typedef pthread_mutex_t _EGLMutex; +typedef mtx_t _EGLMutex; static INLINE void _eglInitMutex(_EGLMutex *m) { - pthread_mutex_init(m, NULL); + mtx_init(m, mtx_plain); } static INLINE void _eglDestroyMutex(_EGLMutex *m) { - pthread_mutex_destroy(m); + mtx_destroy(m); } static INLINE void _eglLockMutex(_EGLMutex *m) { - pthread_mutex_lock(m); + mtx_lock(m); } static INLINE void _eglUnlockMutex(_EGLMutex *m) { - pthread_mutex_unlock(m); + mtx_unlock(m); } -#define _EGL_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER +#define _EGL_MUTEX_INITIALIZER _MTX_INITIALIZER_NP -#else - -typedef int _EGLMutex; -static INLINE void _eglInitMutex(_EGLMutex *m) { (void) m; } -static INLINE void _eglDestroyMutex(_EGLMutex *m) { (void) m; } -static INLINE void _eglLockMutex(_EGLMutex *m) { (void) m; } -static INLINE void _eglUnlockMutex(_EGLMutex *m) { (void) m; } - -#define _EGL_MUTEX_INITIALIZER 0 - -#endif #endif /* EGLMUTEX_INCLUDED */ -- 1.8.3.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 4/7] mapi: Use C11 thread abstractions.
From: José Fonseca jfons...@vmware.com --- src/mapi/u_thread.h | 165 +--- 1 file changed, 13 insertions(+), 152 deletions(-) diff --git a/src/mapi/u_thread.h b/src/mapi/u_thread.h index 31999c4..75fbec6 100644 --- a/src/mapi/u_thread.h +++ b/src/mapi/u_thread.h @@ -46,12 +46,7 @@ #include stdlib.h #include u_compiler.h -#if defined(HAVE_PTHREAD) -#include pthread.h /* POSIX threads headers */ -#endif -#ifdef _WIN32 -#include windows.h -#endif +#include c11/threads.h #if defined(HAVE_PTHREAD) || defined(_WIN32) #ifndef THREADS @@ -79,43 +74,32 @@ extern C { #endif -/* - * POSIX threads. This should be your choice in the Unix world - * whenever possible. When building with POSIX threads, be sure - * to enable any compiler flags which will cause the MT-safe - * libc (if one exists) to be used when linking, as well as any - * header macros for MT-safe errno, etc. For Solaris, this is the -mt - * compiler flag. On Solaris with gcc, use -D_REENTRANT to enable - * proper compiling for MT-safe libc etc. - */ -#if defined(HAVE_PTHREAD) - struct u_tsd { - pthread_key_t key; + tss_t key; unsigned initMagic; }; -typedef pthread_mutex_t u_mutex; +typedef mtx_t u_mutex; #define u_mutex_declare_static(name) \ - static u_mutex name = PTHREAD_MUTEX_INITIALIZER + static u_mutex name = _MTX_INITIALIZER_NP -#define u_mutex_init(name)pthread_mutex_init((name), NULL) -#define u_mutex_destroy(name) pthread_mutex_destroy((name)) -#define u_mutex_lock(name)(void) pthread_mutex_lock((name)) -#define u_mutex_unlock(name) (void) pthread_mutex_unlock((name)) +#define u_mutex_init(name)mtx_init((name), mtx_plain) +#define u_mutex_destroy(name) mtx_destroy((name)) +#define u_mutex_lock(name)(void) mtx_lock((name)) +#define u_mutex_unlock(name) (void) mtx_unlock((name)) static INLINE unsigned long u_thread_self(void) { - return (unsigned long) pthread_self(); + return (unsigned long) thrd_current(); } static INLINE void u_tsd_init(struct u_tsd *tsd) { - if (pthread_key_create(tsd-key, NULL/*free*/) != 0) { + if (tss_create(tsd-key, NULL/*free*/) != 0) { perror(INIT_TSD_ERROR); exit(-1); } @@ -129,7 +113,7 @@ u_tsd_get(struct u_tsd *tsd) if (tsd-initMagic != INIT_MAGIC) { u_tsd_init(tsd); } - return pthread_getspecific(tsd-key); + return tss_get(tsd-key); } @@ -139,56 +123,12 @@ u_tsd_set(struct u_tsd *tsd, void *ptr) if (tsd-initMagic != INIT_MAGIC) { u_tsd_init(tsd); } - if (pthread_setspecific(tsd-key, ptr) != 0) { + if (tss_set(tsd-key, ptr) != 0) { perror(SET_TSD_ERROR); exit(-1); } } -#endif /* HAVE_PTHREAD */ - - -/* - * Windows threads. Should work with Windows NT and 95. - * IMPORTANT: Link with multithreaded runtime library when THREADS are - * used! - */ -#ifdef _WIN32 - -struct u_tsd { - DWORD key; - unsigned initMagic; -}; - -typedef CRITICAL_SECTION u_mutex; - -/* http://locklessinc.com/articles/pthreads_on_windows/ */ -#define u_mutex_declare_static(name) \ - static u_mutex name = {(PCRITICAL_SECTION_DEBUG)-1, -1, 0, 0, 0, 0} - -#define u_mutex_init(name)InitializeCriticalSection(name) -#define u_mutex_destroy(name) DeleteCriticalSection(name) -#define u_mutex_lock(name)EnterCriticalSection(name) -#define u_mutex_unlock(name) LeaveCriticalSection(name) - -static INLINE unsigned long -u_thread_self(void) -{ - return GetCurrentThreadId(); -} - - -static INLINE void -u_tsd_init(struct u_tsd *tsd) -{ - tsd-key = TlsAlloc(); - if (tsd-key == TLS_OUT_OF_INDEXES) { - perror(INIT_TSD_ERROR); - exit(-1); - } - tsd-initMagic = INIT_MAGIC; -} - static INLINE void u_tsd_destroy(struct u_tsd *tsd) @@ -196,90 +136,11 @@ u_tsd_destroy(struct u_tsd *tsd) if (tsd-initMagic != INIT_MAGIC) { return; } - TlsFree(tsd-key); + tss_delete(tsd-key); tsd-initMagic = 0x0; } -static INLINE void * -u_tsd_get(struct u_tsd *tsd) -{ - if (tsd-initMagic != INIT_MAGIC) { - u_tsd_init(tsd); - } - return TlsGetValue(tsd-key); -} - - -static INLINE void -u_tsd_set(struct u_tsd *tsd, void *ptr) -{ - /* the following code assumes that the struct u_tsd has been initialized - to zero at creation */ - if (tsd-initMagic != INIT_MAGIC) { - u_tsd_init(tsd); - } - if (TlsSetValue(tsd-key, ptr) == 0) { - perror(SET_TSD_ERROR); - exit(-1); - } -} - -#endif /* _WIN32 */ - - -/* - * THREADS not defined - */ -#ifndef THREADS - -struct u_tsd { - unsigned initMagic; -}; - -typedef unsigned u_mutex; - -#define u_mutex_declare_static(name) static u_mutex name = 0 -#define u_mutex_init(name) (void) name -#define u_mutex_destroy(name) (void) name -#define u_mutex_lock(name) (void) name -#define u_mutex_unlock(name) (void) name - -/* - * no-op functions - */ - -static INLINE unsigned long -u_thread_self(void) -{ -
[Mesa-dev] [PATCH 1/7] os: Remove pipe_static_condvar.
From: José Fonseca jfons...@vmware.com Never used. --- src/gallium/auxiliary/os/os_thread.h | 12 1 file changed, 12 deletions(-) diff --git a/src/gallium/auxiliary/os/os_thread.h b/src/gallium/auxiliary/os/os_thread.h index 4528abb..d16f36d 100644 --- a/src/gallium/auxiliary/os/os_thread.h +++ b/src/gallium/auxiliary/os/os_thread.h @@ -105,9 +105,6 @@ typedef pthread_mutex_t pipe_mutex; */ typedef pthread_cond_t pipe_condvar; -#define pipe_static_condvar(mutex) \ - static pipe_condvar mutex = PTHREAD_COND_INITIALIZER - #define pipe_condvar_init(cond)\ pthread_cond_init((cond), NULL) @@ -187,9 +184,6 @@ typedef CRITICAL_SECTION pipe_mutex; */ typedef CONDITION_VARIABLE pipe_condvar; -#define pipe_static_condvar(cond) \ - /*static*/ pipe_condvar cond = CONDITION_VARIABLE_INIT - #define pipe_condvar_init(cond) \ InitializeConditionVariable((cond)) @@ -213,9 +207,6 @@ typedef CONDITION_VARIABLE pipe_condvar; */ typedef DWORD pipe_condvar; -#define pipe_static_condvar(cond) \ - /*static*/ pipe_condvar cond = 1 - #define pipe_condvar_init(cond) \ (void) (cond = 1) @@ -284,9 +275,6 @@ typedef unsigned pipe_mutex; typedef int64_t pipe_condvar; -#define pipe_static_condvar(condvar) \ - static pipe_condvar condvar = 1000 - #define pipe_condvar_init(condvar) \ (void) (condvar = 1000) -- 1.8.3.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 6/7] rbug: Update for PIPE_THREAD_ROUTINE returning 0.
From: José Fonseca jfons...@vmware.com --- src/gallium/drivers/rbug/rbug_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/rbug/rbug_core.c b/src/gallium/drivers/rbug/rbug_core.c index 7cc9f79..c5b26b8 100644 --- a/src/gallium/drivers/rbug/rbug_core.c +++ b/src/gallium/drivers/rbug/rbug_core.c @@ -810,7 +810,7 @@ PIPE_THREAD_ROUTINE(rbug_thread, void_tr_rbug) if (s 0) { debug_printf(rbug_rbug - failed to listen\n); - return NULL; + return 0; } u_socket_block(s, false); -- 1.8.3.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 3/7] gallium: Use C11 threads.h.
From: José Fonseca jfons...@vmware.com Note that PIPE_ROUTINE now returns an int. --- src/gallium/auxiliary/os/os_thread.h | 262 +++--- src/gallium/drivers/llvmpipe/lp_rast.c| 2 +- src/gallium/drivers/rbug/rbug_core.c | 2 +- src/gallium/tests/unit/pipe_barrier_test.c| 2 +- src/gallium/winsys/radeon/drm/radeon_drm_winsys.c | 2 +- 5 files changed, 36 insertions(+), 234 deletions(-) diff --git a/src/gallium/auxiliary/os/os_thread.h b/src/gallium/auxiliary/os/os_thread.h index d16f36d..aae40c2 100644 --- a/src/gallium/auxiliary/os/os_thread.h +++ b/src/gallium/auxiliary/os/os_thread.h @@ -40,271 +40,97 @@ #include pipe/p_compiler.h #include util/u_debug.h /* for assert */ +#include c11/threads.h -#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_CYGWIN) || defined(PIPE_OS_HURD) - -#include pthread.h /* POSIX threads headers */ -#include stdio.h /* for perror() */ +#ifdef HAVE_PTHREAD #include signal.h +#endif /* pipe_thread */ -typedef pthread_t pipe_thread; +typedef thrd_t pipe_thread; #define PIPE_THREAD_ROUTINE( name, param ) \ - void *name( void *param ) + int name( void *param ) -static INLINE pipe_thread pipe_thread_create( void *(* routine)( void *), void *param ) +static INLINE pipe_thread pipe_thread_create( PIPE_THREAD_ROUTINE((*routine), ), void *param ) { pipe_thread thread; +#ifdef HAVE_PTHREAD sigset_t saved_set, new_set; int ret; sigfillset(new_set); pthread_sigmask(SIG_SETMASK, new_set, saved_set); - ret = pthread_create( thread, NULL, routine, param ); + ret = thrd_create( thread, routine, param ); pthread_sigmask(SIG_SETMASK, saved_set, NULL); +#else + int ret; + ret = thrd_create( thread, routine, param ); +#endif if (ret) return 0; + return thread; } static INLINE int pipe_thread_wait( pipe_thread thread ) { - return pthread_join( thread, NULL ); + return thrd_join( thread, NULL ); } static INLINE int pipe_thread_destroy( pipe_thread thread ) { - return pthread_detach( thread ); + return thrd_detach( thread ); } /* pipe_mutex */ -typedef pthread_mutex_t pipe_mutex; +typedef mtx_t pipe_mutex; #define pipe_static_mutex(mutex) \ - static pipe_mutex mutex = PTHREAD_MUTEX_INITIALIZER + static pipe_mutex mutex = _MTX_INITIALIZER_NP #define pipe_mutex_init(mutex) \ - (void) pthread_mutex_init((mutex), NULL) + (void) mtx_init((mutex), mtx_plain) #define pipe_mutex_destroy(mutex) \ - pthread_mutex_destroy((mutex)) + mtx_destroy((mutex)) #define pipe_mutex_lock(mutex) \ - (void) pthread_mutex_lock((mutex)) + (void) mtx_lock((mutex)) #define pipe_mutex_unlock(mutex) \ - (void) pthread_mutex_unlock((mutex)) + (void) mtx_unlock((mutex)) /* pipe_condvar */ -typedef pthread_cond_t pipe_condvar; +typedef cnd_t pipe_condvar; #define pipe_condvar_init(cond)\ - pthread_cond_init((cond), NULL) - -#define pipe_condvar_destroy(cond) \ - pthread_cond_destroy((cond)) - -#define pipe_condvar_wait(cond, mutex) \ - pthread_cond_wait((cond), (mutex)) - -#define pipe_condvar_signal(cond) \ - pthread_cond_signal((cond)) - -#define pipe_condvar_broadcast(cond) \ - pthread_cond_broadcast((cond)) - - - -#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER) - -#include windows.h - -/* pipe_thread - */ -typedef HANDLE pipe_thread; - -#define PIPE_THREAD_ROUTINE( name, param ) \ - void * WINAPI name( void *param ) - -static INLINE pipe_thread pipe_thread_create( void *(WINAPI * routine)( void *), void *param ) -{ - DWORD id; - return CreateThread( NULL, 0, (LPTHREAD_START_ROUTINE) routine, param, 0, id ); -} - -static INLINE int pipe_thread_wait( pipe_thread thread ) -{ - if (WaitForSingleObject( thread, INFINITE ) == WAIT_OBJECT_0) - return 0; - return -1; -} - -static INLINE int pipe_thread_destroy( pipe_thread thread ) -{ - if (CloseHandle( thread )) - return 0; - return -1; -} - - -/* pipe_mutex - */ -typedef CRITICAL_SECTION pipe_mutex; - -/* http://locklessinc.com/articles/pthreads_on_windows/ */ -#define pipe_static_mutex(mutex) \ - static pipe_mutex mutex = {(PCRITICAL_SECTION_DEBUG)-1, -1, 0, 0, 0, 0} - -#define pipe_mutex_init(mutex) \ - InitializeCriticalSection(mutex) - -#define pipe_mutex_destroy(mutex) \ - DeleteCriticalSection(mutex) - -#define pipe_mutex_lock(mutex) \ - EnterCriticalSection(mutex) - -#define pipe_mutex_unlock(mutex) \ - LeaveCriticalSection(mutex) - -/* TODO: Need a macro to declare I don't care about WinXP compatibilty */ -#if 0 defined (_WIN32_WINNT) (_WIN32_WINNT = 0x0600) -/* CONDITION_VARIABLE is only available on newer versions of Windows - * (Server 2008/Vista or later). - * http://msdn.microsoft.com/en-us/library/ms682052(VS.85).aspx - * - * pipe_condvar - */ -typedef CONDITION_VARIABLE pipe_condvar; - -#define
[Mesa-dev] [PATCH 1/2] st/mesa: simplify shader limit initialization code
Make use of the new gl_constants::Program[] array. --- src/mesa/state_tracker/st_extensions.c | 31 src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 20 +- src/mesa/state_tracker/st_program.h| 18 3 files changed, 28 insertions(+), 41 deletions(-) diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c index c17601a..cc63b36 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -38,6 +38,8 @@ #include st_context.h #include st_extensions.h #include st_format.h +#include st_program.h + static unsigned _min(unsigned a, unsigned b) { @@ -68,8 +70,8 @@ void st_init_limits(struct st_context *st) { struct pipe_screen *screen = st-pipe-screen; struct gl_constants *c = st-ctx-Const; - unsigned sh; boolean can_ubo = TRUE; + int i; c-MaxTextureLevels = _min(screen-get_param(screen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS), @@ -149,27 +151,12 @@ void st_init_limits(struct st_context *st) can_ubo = FALSE; } - for (sh = 0; sh PIPE_SHADER_TYPES; ++sh) { - struct gl_shader_compiler_options *options; - struct gl_program_constants *pc; - - switch (sh) { - case PIPE_SHADER_FRAGMENT: - pc = c-Program[MESA_SHADER_FRAGMENT]; - options = st-ctx-ShaderCompilerOptions[MESA_SHADER_FRAGMENT]; - break; - case PIPE_SHADER_VERTEX: - pc = c-Program[MESA_SHADER_VERTEX]; - options = st-ctx-ShaderCompilerOptions[MESA_SHADER_VERTEX]; - break; - case PIPE_SHADER_GEOMETRY: - pc = c-Program[MESA_SHADER_GEOMETRY]; - options = st-ctx-ShaderCompilerOptions[MESA_SHADER_GEOMETRY]; - break; - default: - /* compute shader, etc. */ - continue; - } + /* Note: we only loop over the currently supported gallium shader types */ + for (i = MESA_SHADER_VERTEX; i = MESA_SHADER_FRAGMENT; i++) { + unsigned sh = st_shader_stage_to_ptarget(i); + struct gl_shader_compiler_options *options = + st-ctx-ShaderCompilerOptions[i]; + struct gl_program_constants *pc = c-Program[i]; pc-MaxTextureImageUnits = _min(screen-get_shader_param(screen, sh, diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index 73c39eb..d16f1fb 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -5023,24 +5023,6 @@ out: } /* - End TGSI code -- */ - -static unsigned -shader_stage_to_ptarget(gl_shader_stage stage) -{ - switch (stage) { - case MESA_SHADER_VERTEX: - return PIPE_SHADER_VERTEX; - case MESA_SHADER_FRAGMENT: - return PIPE_SHADER_FRAGMENT; - case MESA_SHADER_GEOMETRY: - return PIPE_SHADER_GEOMETRY; - } - - assert(!should not be reached); - return PIPE_SHADER_VERTEX; -} - - /** * Convert a shader's GLSL IR into a Mesa gl_program, although without * generating Mesa IR. @@ -5057,7 +5039,7 @@ get_mesa_program(struct gl_context *ctx, struct gl_shader_compiler_options *options = ctx-ShaderCompilerOptions[_mesa_shader_enum_to_shader_stage(shader-Type)]; struct pipe_screen *pscreen = ctx-st-pipe-screen; - unsigned ptarget = shader_stage_to_ptarget(shader-Stage); + unsigned ptarget = st_shader_stage_to_ptarget(shader-Stage); validate_ir_tree(shader-ir); diff --git a/src/mesa/state_tracker/st_program.h b/src/mesa/state_tracker/st_program.h index c764dc9..8b2f170 100644 --- a/src/mesa/state_tracker/st_program.h +++ b/src/mesa/state_tracker/st_program.h @@ -319,4 +319,22 @@ extern void st_print_current_vertex_program(void); +/** Convert MESA_SHADER_x to PIPE_SHADER_x */ +static INLINE unsigned +st_shader_stage_to_ptarget(gl_shader_stage stage) +{ + switch (stage) { + case MESA_SHADER_VERTEX: + return PIPE_SHADER_VERTEX; + case MESA_SHADER_FRAGMENT: + return PIPE_SHADER_FRAGMENT; + case MESA_SHADER_GEOMETRY: + return PIPE_SHADER_GEOMETRY; + } + + assert(!should not be reached); + return PIPE_SHADER_VERTEX; +} + + #endif -- 1.7.10.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/2] st/mesa: remove _min(), _maxf(), _clamp()
Just use the existing MIN2, MAX2 and CLAMP macros. --- src/mesa/state_tracker/st_extensions.c | 80 ++-- 1 file changed, 34 insertions(+), 46 deletions(-) diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c index cc63b36..faf0e77 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -41,26 +41,6 @@ #include st_program.h -static unsigned _min(unsigned a, unsigned b) -{ - return (a b) ? a : b; -} - -static float _maxf(float a, float b) -{ - return (a b) ? a : b; -} - -static int _clamp(int a, int min, int max) -{ - if (a min) - return min; - else if (a max) - return max; - else - return a; -} - /** * Query driver to get implementation limits. @@ -74,25 +54,25 @@ void st_init_limits(struct st_context *st) int i; c-MaxTextureLevels - = _min(screen-get_param(screen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS), + = MIN2(screen-get_param(screen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS), MAX_TEXTURE_LEVELS); c-Max3DTextureLevels - = _min(screen-get_param(screen, PIPE_CAP_MAX_TEXTURE_3D_LEVELS), + = MIN2(screen-get_param(screen, PIPE_CAP_MAX_TEXTURE_3D_LEVELS), MAX_3D_TEXTURE_LEVELS); c-MaxCubeTextureLevels - = _min(screen-get_param(screen, PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS), + = MIN2(screen-get_param(screen, PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS), MAX_CUBE_TEXTURE_LEVELS); c-MaxTextureRectSize - = _min(1 (c-MaxTextureLevels - 1), MAX_TEXTURE_RECT_SIZE); + = MIN2(1 (c-MaxTextureLevels - 1), MAX_TEXTURE_RECT_SIZE); c-MaxArrayTextureLayers = screen-get_param(screen, PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS); c-MaxCombinedTextureImageUnits - = _min(screen-get_param(screen, PIPE_CAP_MAX_COMBINED_SAMPLERS), + = MIN2(screen-get_param(screen, PIPE_CAP_MAX_COMBINED_SAMPLERS), MAX_COMBINED_TEXTURE_IMAGE_UNITS); /* Define max viewport size and max renderbuffer size in terms of @@ -104,26 +84,27 @@ void st_init_limits(struct st_context *st) c-MaxRenderbufferSize = c-MaxTextureRectSize; c-MaxDrawBuffers = c-MaxColorAttachments = - _clamp(screen-get_param(screen, PIPE_CAP_MAX_RENDER_TARGETS), + CLAMP(screen-get_param(screen, PIPE_CAP_MAX_RENDER_TARGETS), 1, MAX_DRAW_BUFFERS); - c-MaxDualSourceDrawBuffers - = _clamp(screen-get_param(screen, PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS), - 0, MAX_DRAW_BUFFERS); + c-MaxDualSourceDrawBuffers = + CLAMP(screen-get_param(screen, + PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS), +0, MAX_DRAW_BUFFERS); c-MaxLineWidth - = _maxf(1.0f, screen-get_paramf(screen, - PIPE_CAPF_MAX_LINE_WIDTH)); + = MAX2(1.0f, screen-get_paramf(screen, + PIPE_CAPF_MAX_LINE_WIDTH)); c-MaxLineWidthAA - = _maxf(1.0f, screen-get_paramf(screen, - PIPE_CAPF_MAX_LINE_WIDTH_AA)); + = MAX2(1.0f, screen-get_paramf(screen, + PIPE_CAPF_MAX_LINE_WIDTH_AA)); c-MaxPointSize - = _maxf(1.0f, screen-get_paramf(screen, - PIPE_CAPF_MAX_POINT_WIDTH)); + = MAX2(1.0f, screen-get_paramf(screen, + PIPE_CAPF_MAX_POINT_WIDTH)); c-MaxPointSizeAA - = _maxf(1.0f, screen-get_paramf(screen, - PIPE_CAPF_MAX_POINT_WIDTH_AA)); + = MAX2(1.0f, screen-get_paramf(screen, + PIPE_CAPF_MAX_POINT_WIDTH_AA)); /* called after _mesa_create_context/_mesa_init_point, fix default user * settable max point size up */ @@ -135,7 +116,7 @@ void st_init_limits(struct st_context *st) c-MinPointSizeAA = 0.0f; c-MaxTextureMaxAnisotropy - = _maxf(2.0f, screen-get_paramf(screen, + = MAX2(2.0f, screen-get_paramf(screen, PIPE_CAPF_MAX_TEXTURE_ANISOTROPY)); c-MaxTextureLodBias @@ -159,7 +140,7 @@ void st_init_limits(struct st_context *st) struct gl_program_constants *pc = c-Program[i]; pc-MaxTextureImageUnits = - _min(screen-get_shader_param(screen, sh, + MIN2(screen-get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS), MAX_TEXTURE_IMAGE_UNITS); @@ -176,7 +157,7 @@ void st_init_limits(struct st_context *st) pc-MaxTemps = pc-MaxNativeTemps = screen-get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_TEMPS); pc-MaxAddressRegs = pc-MaxNativeAddressRegs = - _min(screen-get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_ADDRS), + MIN2(screen-get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_ADDRS),
Re: [Mesa-dev] [PATCH 4/5] glsl: Vectorize multiple scalar assignments
On 01/08/2014 12:43 PM, Matt Turner wrote: Reduces vertex shader instruction counts in DOTA2 by 6.42%, L4D2 by 4.61%, and CS:GO by 5.71%. total instructions in shared programs: 1500153 - 1498191 (-0.13%) instructions in affected programs: 59919 - 57957 (-3.27%) --- src/glsl/Makefile.sources | 1 + src/glsl/glsl_parser_extras.cpp | 4 + src/glsl/ir_optimization.h | 1 + src/glsl/opt_vectorize.cpp | 319 4 files changed, 325 insertions(+) create mode 100644 src/glsl/opt_vectorize.cpp diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources index 2e81ded..e69c1ac 100644 --- a/src/glsl/Makefile.sources +++ b/src/glsl/Makefile.sources @@ -99,6 +99,7 @@ LIBGLSL_FILES = \ $(GLSL_SRCDIR)/opt_structure_splitting.cpp \ $(GLSL_SRCDIR)/opt_swizzle_swizzle.cpp \ $(GLSL_SRCDIR)/opt_tree_grafting.cpp \ + $(GLSL_SRCDIR)/opt_vectorize.cpp \ $(GLSL_SRCDIR)/s_expression.cpp \ $(GLSL_SRCDIR)/strtod.c diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp index c759569..3db7eaa 100644 --- a/src/glsl/glsl_parser_extras.cpp +++ b/src/glsl/glsl_parser_extras.cpp @@ -1594,6 +1594,10 @@ do_common_optimization(exec_list *ir, bool linked, if (options-OptimizeForAOS !linked) progress = opt_flip_matrices(ir) || progress; + if (linked options-OptimizeForAOS) { + progress = do_vectorize(ir) || progress; + } + if (linked) progress = do_dead_code(ir, uniform_locations_assigned) || progress; else diff --git a/src/glsl/ir_optimization.h b/src/glsl/ir_optimization.h index 3ca9f57..055d655 100644 --- a/src/glsl/ir_optimization.h +++ b/src/glsl/ir_optimization.h @@ -98,6 +98,7 @@ bool do_mat_op_to_vec(exec_list *instructions); bool do_noop_swizzle(exec_list *instructions); bool do_structure_splitting(exec_list *instructions); bool do_swizzle_swizzle(exec_list *instructions); +bool do_vectorize(exec_list *instructions); bool do_tree_grafting(exec_list *instructions); bool do_vec_index_to_cond_assign(exec_list *instructions); bool do_vec_index_to_swizzle(exec_list *instructions); diff --git a/src/glsl/opt_vectorize.cpp b/src/glsl/opt_vectorize.cpp new file mode 100644 index 000..9ca811a --- /dev/null +++ b/src/glsl/opt_vectorize.cpp @@ -0,0 +1,319 @@ +/* + * Copyright © 2013 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. + */ + +/** + * \file opt_vectorize.cpp + * + * Combines scalar assignments of the same expression (modulo swizzle) to + * multiple channels of the same variable into a single vectorized expression + * and assignment. + * + * Many generated shaders contain scalarized code. That is, they contain + * + * r1.x = log2(v0.x); + * r1.y = log2(v0.y); + * r1.z = log2(v0.z); + * + * rather than + * + * r1.xyz = log2(v0.xyz); + * + * We look for consecutive assignments of the same expression (modulo swizzle) + * to each channel of the same variable. + * + * For instance, we want to convert these three scalar operations + * + * (assign (x) (var_ref r1) (expression float log2 (swiz x (var_ref v0 + * (assign (y) (var_ref r1) (expression float log2 (swiz y (var_ref v0 + * (assign (z) (var_ref r1) (expression float log2 (swiz z (var_ref v0 + * + * into a single vector operation + * + * (assign (xyz) (var_ref r1) (expression vec3 log2 (swiz xyz (var_ref v0 I think it's worth adding a note that this pass only attempts to combine assignments that are sequential. The above example gets fully vectorized, but this sequence would not: (assign (x) (var_ref r1) (expression float log2 (swiz x (var_ref v0 (assign (x) (var_ref r2) (expression float log2 (swiz y (var_ref v0 (assign (y) (var_ref r1) (expression float log2 (swiz z (var_ref v0 (assign (y)
Re: [Mesa-dev] [PATCH 7/7] c11: Make TIME_UTC a conditional macro.
This series is pretty much what I proposed several months ago, rebased on top of master, with minor if any tweaks. Still to do is remove the deprecated abstractions (which now are mere wrappers of the c11 ones). That said, this series is already useful as is, not only because of the code de-duplication, but also because the Windows conditional var implemention in master is poll-based so performs quite badly, in particular llvmpipe with many threads. Which is fixed here. IMHO the rest can be done as time permits... Jose - Original Message - From: José Fonseca jfons...@vmware.com Some system headers already define it, so this prevents conflict. --- include/c11/threads.h | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/c11/threads.h b/include/c11/threads.h index 678774c..4a4079d 100644 --- a/include/c11/threads.h +++ b/include/c11/threads.h @@ -10,6 +10,10 @@ #include time.h +#ifndef TIME_UTC +#define TIME_UTC 1 +#endif + #include c99_compat.h /* for `inline` */ /* types */ @@ -39,8 +43,6 @@ enum { thrd_nomem// out of memory }; -enum { TIME_UTC = 1 }; - /*-- functions --*/ #if defined(_WIN32) !defined(__CYGWIN__) -- 1.8.3.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 7/7] c11: Make TIME_UTC a conditional macro.
LGTM. Reviewed-by: Brian Paul bri...@vmware.com On 01/09/2014 12:32 PM, Jose Fonseca wrote: This series is pretty much what I proposed several months ago, rebased on top of master, with minor if any tweaks. Still to do is remove the deprecated abstractions (which now are mere wrappers of the c11 ones). That said, this series is already useful as is, not only because of the code de-duplication, but also because the Windows conditional var implemention in master is poll-based so performs quite badly, in particular llvmpipe with many threads. Which is fixed here. IMHO the rest can be done as time permits... Jose - Original Message - From: José Fonseca jfons...@vmware.com Some system headers already define it, so this prevents conflict. --- include/c11/threads.h | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/c11/threads.h b/include/c11/threads.h index 678774c..4a4079d 100644 --- a/include/c11/threads.h +++ b/include/c11/threads.h @@ -10,6 +10,10 @@ #include time.h +#ifndef TIME_UTC +#define TIME_UTC 1 +#endif + #include c99_compat.h /* for `inline` */ /* types */ @@ -39,8 +43,6 @@ enum { thrd_nomem// out of memory }; -enum { TIME_UTC = 1 }; - /*-- functions --*/ #if defined(_WIN32) !defined(__CYGWIN__) -- 1.8.3.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 7/7] c11: Make TIME_UTC a conditional macro.
This should get squashed with patch #2 when you push this. That will prevent possible build breaks while bisecting. On 01/09/2014 11:20 AM, jfons...@vmware.com wrote: From: José Fonseca jfons...@vmware.com Some system headers already define it, so this prevents conflict. --- include/c11/threads.h | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/c11/threads.h b/include/c11/threads.h index 678774c..4a4079d 100644 --- a/include/c11/threads.h +++ b/include/c11/threads.h @@ -10,6 +10,10 @@ #include time.h +#ifndef TIME_UTC +#define TIME_UTC 1 +#endif + #include c99_compat.h /* for `inline` */ /* types */ @@ -39,8 +43,6 @@ enum { thrd_nomem// out of memory }; -enum { TIME_UTC = 1 }; - /*-- functions --*/ #if defined(_WIN32) !defined(__CYGWIN__) ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 2/7] c11: Import threads.h emulation library.
Assuming patch 7 gets squashed in (I sent a comment on that patch), Acked-by: Ian Romanick ian.d.roman...@intel.com On 01/09/2014 11:20 AM, jfons...@vmware.com wrote: From: José Fonseca jfons...@vmware.com Implementation is based of https://gist.github.com/2223710 with the following modifications: - inline implementatation - retain XP compatability - add temporary hack for static mutex initializers (as they are not part of the stack but still widely used internally). --- include/c11/threads.h | 56 + include/c11/threads_posix.h | 346 ++ include/c11/threads_win32.h | 588 3 files changed, 990 insertions(+) create mode 100644 include/c11/threads.h create mode 100644 include/c11/threads_posix.h create mode 100644 include/c11/threads_win32.h diff --git a/include/c11/threads.h b/include/c11/threads.h new file mode 100644 index 000..678774c --- /dev/null +++ b/include/c11/threads.h @@ -0,0 +1,56 @@ +/* + * C11 threads.h emulation library + * + * (C) Copyright yohhoy 2012. + * Distributed under the Boost Software License, Version 1.0. + * (See copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef EMULATED_THREADS_H_INCLUDED_ +#define EMULATED_THREADS_H_INCLUDED_ + +#include time.h + +#include c99_compat.h /* for `inline` */ + +/* types */ +typedef void (*tss_dtor_t)(void*); +typedef int (*thrd_start_t)(void*); + +struct xtime { +time_t sec; +long nsec; +}; +typedef struct xtime xtime; + + +/* enumeration constants */ +enum { +mtx_plain = 0, +mtx_try = 1, +mtx_timed = 2, +mtx_recursive = 4 +}; + +enum { +thrd_success = 0, // succeeded +thrd_timeout, // timeout +thrd_error, // failed +thrd_busy,// resource busy +thrd_nomem// out of memory +}; + +enum { TIME_UTC = 1 }; + +/*-- functions --*/ + +#if defined(_WIN32) !defined(__CYGWIN__) +#include threads_win32.h +#elif defined(__unix__) || defined(__unix) +#include threads_posix.h +#else +#error Not supported on this platform. +#endif + + + +#endif /* EMULATED_THREADS_H_INCLUDED_ */ diff --git a/include/c11/threads_posix.h b/include/c11/threads_posix.h new file mode 100644 index 000..463c93f --- /dev/null +++ b/include/c11/threads_posix.h @@ -0,0 +1,346 @@ +/* + * C11 threads.h emulation library + * + * (C) Copyright yohhoy 2012. + * Distributed under the Boost Software License, Version 1.0. + * (See copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#include stdlib.h +#include assert.h +#include limits.h +#include errno.h +#include unistd.h +#include sched.h +#include stdint.h /* for intptr_t */ + +/* +Configuration macro: + + EMULATED_THREADS_USE_NATIVE_TIMEDLOCK +Use pthread_mutex_timedlock() for `mtx_timedlock()' +Otherwise use mtx_trylock() + *busy loop* emulation. +*/ +#if !defined(__CYGWIN__) +#define EMULATED_THREADS_USE_NATIVE_TIMEDLOCK +#endif + + +#include pthread.h + +/* macros */ +#define ONCE_FLAG_INIT PTHREAD_ONCE_INIT +#ifdef INIT_ONCE_STATIC_INIT +#define TSS_DTOR_ITERATIONS PTHREAD_DESTRUCTOR_ITERATIONS +#else +#define TSS_DTOR_ITERATIONS 1 // assume TSS dtor MAY be called at least once. +#endif + +// FIXME: temporary non-standard hack to ease transition +#define _MTX_INITIALIZER_NP PTHREAD_MUTEX_INITIALIZER + +/* types */ +typedef pthread_cond_t cnd_t; +typedef pthread_t thrd_t; +typedef pthread_key_t tss_t; +typedef pthread_mutex_t mtx_t; +typedef pthread_once_t once_flag; + + +/* +Implementation limits: + - Conditionally emulation for mutex with timeout +(see EMULATED_THREADS_USE_NATIVE_TIMEDLOCK macro) +*/ +struct impl_thrd_param { +thrd_start_t func; +void *arg; +}; + +static inline void * +impl_thrd_routine(void *p) +{ +struct impl_thrd_param pack = *((struct impl_thrd_param *)p); +free(p); +return (void*)(intptr_t)pack.func(pack.arg); +} + + +/*--- 7.25.2 Initialization functions ---*/ +// 7.25.2.1 +static inline void +call_once(once_flag *flag, void (*func)(void)) +{ +pthread_once(flag, func); +} + + +/*- 7.25.3 Condition variable functions -*/ +// 7.25.3.1 +static inline int +cnd_broadcast(cnd_t *cond) +{ +if (!cond) return thrd_error; +pthread_cond_broadcast(cond); +return thrd_success; +} + +// 7.25.3.2 +static inline void +cnd_destroy(cnd_t *cond) +{ +assert(cond); +pthread_cond_destroy(cond); +} + +// 7.25.3.3 +static inline int +cnd_init(cnd_t *cond) +{ +if (!cond) return thrd_error; +
Re: [Mesa-dev] [PATCH 5/7] egl: Use C11 thread abstractions.
I'd like to hear Kristian and / or Chad's opinion, but I'd like to take this a step further and remove the _egl* wrappers altogether... as a follow-on patch. For now, this patch is Reviewed-by: Ian Romanick ian.d.roman...@intel.com On 01/09/2014 11:20 AM, jfons...@vmware.com wrote: From: José Fonseca jfons...@vmware.com --- src/egl/main/eglmutex.h | 26 +++--- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/src/egl/main/eglmutex.h b/src/egl/main/eglmutex.h index 1349e9e..2ec965c 100644 --- a/src/egl/main/eglmutex.h +++ b/src/egl/main/eglmutex.h @@ -31,46 +31,34 @@ #include eglcompiler.h -#ifdef HAVE_PTHREAD -#include pthread.h +#include c11/threads.h -typedef pthread_mutex_t _EGLMutex; +typedef mtx_t _EGLMutex; static INLINE void _eglInitMutex(_EGLMutex *m) { - pthread_mutex_init(m, NULL); + mtx_init(m, mtx_plain); } static INLINE void _eglDestroyMutex(_EGLMutex *m) { - pthread_mutex_destroy(m); + mtx_destroy(m); } static INLINE void _eglLockMutex(_EGLMutex *m) { - pthread_mutex_lock(m); + mtx_lock(m); } static INLINE void _eglUnlockMutex(_EGLMutex *m) { - pthread_mutex_unlock(m); + mtx_unlock(m); } -#define _EGL_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER +#define _EGL_MUTEX_INITIALIZER _MTX_INITIALIZER_NP -#else - -typedef int _EGLMutex; -static INLINE void _eglInitMutex(_EGLMutex *m) { (void) m; } -static INLINE void _eglDestroyMutex(_EGLMutex *m) { (void) m; } -static INLINE void _eglLockMutex(_EGLMutex *m) { (void) m; } -static INLINE void _eglUnlockMutex(_EGLMutex *m) { (void) m; } - -#define _EGL_MUTEX_INITIALIZER 0 - -#endif #endif /* EGLMUTEX_INCLUDED */ ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] Mesa 10.0.2
Mesa 10.0.2 has been released. Mesa 10.0.2 is a bug fix release which fixes bugs fixed since the 10.0.1 release, (see below for a list of changes). The tag in the git repository for Mesa 10.0.2 is 'mesa-10.0.2'. Mesa 10.0.2 is available for download at ftp://freedesktop.org/pub/mesa/10.0.2/ md5sums: de7d14baf0101b697c140d2f47ef27e9 MesaLib-10.0.2.tar.gz 8544c0ab3e438a08b5103421ea15b6d2 MesaLib-10.0.2.tar.bz2 181b0d6c1afca38e98a930d0e564ed90 MesaLib-10.0.2.zip I have verified building from the .tar.bz2 file by doing: tar xjf MesaLib-10.0.2.tar.bz2 cd Mesa-10.0.2 ./configure --enable-gallium-llvm --with-llvm-shared-libs make -j6 make install I have also verified that I pushed the tag. -Carl -- carl.d.wo...@intel.com Changes from 10.0.1 to 10.0.2: Aaron Watry (8): clover: Remove unused variable pipe_loader/sw: close dev-lib when initialization fails radeon/compute: Stop leaking LLVMContexts in radeon_llvm_parse_bitcode r600/compute: Free compiled kernels when deleting compute state r600/compute: Use the correct FREE macro when deleting compute state radeon/llvm: Free target data at end of optimization st/vdpau: Destroy context when initialization fails r600/pipe: Stop leaking context-start_compute_cs_cmd.buf on EG/CM Alex Deucher (1): r600g: fix SUMO2 pci id Alexander von Gluck IV (1): Haiku: Add in public GL kit headers Anuj Phogat (1): mesa: Fix error code generation in glBeginConditionalRender() Carl Worth (3): docs: Add md5sums for the 10.0.1 release. Update version to 10.0.2 docs: Add release notes for 10.0.2 release. Chad Versace (1): i965/gen6: Fix HiZ hang in WebGL Google Maps Erik Faye-Lund (1): glcpp: error on multiple #else/#elif directives Henri Verbeet (1): i915: Add support for gl_FragData[0] reads. Ilia Mirkin (1): nv50: fix a small leak on context destroy Jonathan Liu (2): st/mesa: use pipe_sampler_view_release() llvmpipe: use pipe_sampler_view_release() to avoid segfault Kenneth Graunke (2): i965: Fix 3DSTATE_PUSH_CONSTANT_ALLOC_PS packet creation. Revert mesa: Remove GLXContextID typedef from glx.h. Kevin Rogovin (1): Use line number information from entire function expression Kristian Høgsberg (1): dri_util: Don't assume __DRIcontext-driverPrivate is a gl_context Marek Olšák (2): mesa: fix interpretation of glClearBuffer(drawbuffer) st/mesa: fix glClear with multiple colorbuffers and different formats Paul Berry (2): glsl: Teach ir_variable_refcount about ir_loop::counter variables. glsl: Fix inconsistent assumptions about ir_loop::counter. Vadim Girlin (1): r600g/sb: fix stack size computation on evergreen pgp8quxuHtwom.pgp Description: PGP signature ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] glsl: Optimize open-coded lrp into lrp.
From: Jordan Justen jordan.l.jus...@intel.com total instructions in shared programs: 1498191 - 1487051 (-0.74%) instructions in affected programs: 669388 - 658248 (-1.66%) GAINED:1 LOST: 0 Reviewed-by: Matt Turner matts...@gmail.com --- Looks like my unreviewed 16 patch series from last month makes this patch beneficial. I cleaned some stuff up before sending this out, like 1 - x instead of (x + 1) % 2 and some comments. src/glsl/opt_algebraic.cpp | 52 ++ 1 file changed, 52 insertions(+) diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp index 05a5899..b8b69b9 100644 --- a/src/glsl/opt_algebraic.cpp +++ b/src/glsl/opt_algebraic.cpp @@ -279,6 +279,58 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir) reassociate_constant(ir, 0, op_const[0], op_expr[1]); if (op_const[1] !op_const[0]) reassociate_constant(ir, 1, op_const[1], op_expr[0]); + + /* Replace (-x + y) * a + x and commutative variations with lrp(x, y, a). + * + * (-x + y) * a + x + * (x * -a) + (y * a) + x + * x + (x * -a) + (y * a) + * x * (1 - a) + y * a + * lrp(x, y, a) + */ + for (int mul_pos = 0; mul_pos 2; mul_pos++) { + ir_expression *mul = op_expr[mul_pos]; + + if (!mul || mul-operation != ir_binop_mul) +continue; + + /* Multiply found on one of the operands. Now check for an + * inner addition operation. + */ + for (int inner_add_pos = 0; inner_add_pos 2; inner_add_pos++) { +ir_expression *inner_add = + mul-operands[inner_add_pos]-as_expression(); + +if (!inner_add || inner_add-operation != ir_binop_add) + continue; + +/* Inner addition found on one of the operands. Now check for + * one of the operands of the inner addition to be the negative + * of x_operand. + */ +for (int neg_pos = 0; neg_pos 2; neg_pos++) { + ir_expression *neg = + inner_add-operands[neg_pos]-as_expression(); + + if (!neg || neg-operation != ir_unop_neg) + continue; + + ir_rvalue *x_operand = ir-operands[1 - mul_pos]; + + if (!neg-operands[0]-equals(x_operand)) + continue; + + ir_rvalue *y_operand = inner_add-operands[1 - neg_pos]; + ir_rvalue *a_operand = mul-operands[1 - inner_add_pos]; + + if (x_operand-type != y_operand-type || + x_operand-type != a_operand-type) + continue; + + return lrp(x_operand, y_operand, a_operand); +} + } + } break; case ir_binop_sub: -- 1.8.3.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [Mesa-stable] [PATCH] mesa: implement missing glGet(GL_RGBA_SIGNED_COMPONENTS_EXT) query
Ian Romanick i...@freedesktop.org writes: There are fixes on top of this fix. When they get picked over to the stable branch, I think at least this and the one from 050961.html should get squashed together. http://lists.freedesktop.org/archives/mesa-dev/2014-January/050961.html http://lists.freedesktop.org/archives/mesa-dev/2014-January/050962.html Thanks. I picked-and-squashed the three patches (as they landed on master) over to 10.0, (just after the 10.0.2 release). -Carl pgpco9x3wiyy7.pgp Description: PGP signature ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] Plans for 10.0.3 release
Hi folks, I just released Mesa 10.0.2 (a bit late) and followed it by immediately working through my queue of commits nominated for the stable branch, which I've just pushed out. Since the code for 10.0.2 was done and pushed a week ago, my current plan is to release 10.0.2 just one week from now, (to get back to a schedule of a stable release every two weeks). The state of the queue looks pretty good right now. There are still a handful of patches from early December that have not landed on master yet. I imagine he's waiting for review on those. Then, there are two recent, larger series from Aaron and Chad. For each of these series, there has been some discussion and both authors are planning to come back with a version 2 of their series in response to review. I do want to say that I really enjoy how smooth that stable-release management has been. That's thanks to all of the developers doing such high-quality work. I've not yet encountered a nominated patch that I needed to reject due to a regression or a patch which failed to meet the release-branch criteria. So thanks to all for your attention to detail. I really appreciate it. -Carl -- carl.d.wo...@intel.com pgphR7Q0vYLO9.pgp Description: PGP signature ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] /usr/lib/libglapi.la: No such file or directory
On 01/09/14 12:56, YuGiOhJCJ Mailing-List wrote: So, I see /usr/lib/libglapi.la is missing. I recompile MesaLib-8.0.4 like this: 8.0.4 is from July 10, 2012. Would it be possible to try something newer? ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 3/3] i965/Gen7: Only emit cube face enables for cubes.
On 01/08/2014 01:11 PM, Chris Forbes wrote: This is not observed to actually fix anything, but the PRM says this field must be zero for other surface types. Signed-off-by: Chris Forbes chr...@ijw.co.nz --- src/mesa/drivers/dri/i965/gen7_wm_surface_state.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c b/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c index 761bc3b..bda09a0 100644 --- a/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c +++ b/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c @@ -298,8 +298,11 @@ gen7_update_texture_surface(struct gl_context *ctx, surf[0] = translate_tex_target(tObj-Target) BRW_SURFACE_TYPE_SHIFT | tex_format BRW_SURFACE_FORMAT_SHIFT | - gen7_surface_tiling_mode(mt-region-tiling) | - BRW_SURFACE_CUBEFACE_ENABLES; + gen7_surface_tiling_mode(mt-region-tiling); + + /* mask of faces present in cube map; for other surfaces MBZ. */ + if (tObj-Target == GL_TEXTURE_CUBE_MAP || tObj-Target == GL_TEXTURE_CUBE_MAP_ARRAY) + surf[0] |= BRW_SURFACE_CUBEFACE_ENABLES; if (mt-align_h == 4) surf[0] |= GEN7_SURFACE_VALIGN_4; We also enable it universally on Gen4-6. We should probably be consistent one way or another. This series is: Reviewed-by: Kenneth Graunke kenn...@whitecape.org ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] glsl: Optimize open-coded lrp into lrp.
On Thu, Jan 9, 2014 at 12:14 PM, Matt Turner matts...@gmail.com wrote: From: Jordan Justen jordan.l.jus...@intel.com total instructions in shared programs: 1498191 - 1487051 (-0.74%) instructions in affected programs: 669388 - 658248 (-1.66%) GAINED:1 LOST: 0 This is with the closed shader-db? I think the lost cases were L4D2. Could you retain my Signed-off-by? Reviewed-by: Matt Turner matts...@gmail.com --- Looks like my unreviewed 16 patch series from last month makes this patch beneficial. Nice. :) I cleaned some stuff up before sending this out, like 1 - x instead of (x + 1) % 2 and some comments. These changes look good. Thanks for reviving this patch. -Jordan src/glsl/opt_algebraic.cpp | 52 ++ 1 file changed, 52 insertions(+) diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp index 05a5899..b8b69b9 100644 --- a/src/glsl/opt_algebraic.cpp +++ b/src/glsl/opt_algebraic.cpp @@ -279,6 +279,58 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir) reassociate_constant(ir, 0, op_const[0], op_expr[1]); if (op_const[1] !op_const[0]) reassociate_constant(ir, 1, op_const[1], op_expr[0]); + + /* Replace (-x + y) * a + x and commutative variations with lrp(x, y, a). + * + * (-x + y) * a + x + * (x * -a) + (y * a) + x + * x + (x * -a) + (y * a) + * x * (1 - a) + y * a + * lrp(x, y, a) + */ + for (int mul_pos = 0; mul_pos 2; mul_pos++) { + ir_expression *mul = op_expr[mul_pos]; + + if (!mul || mul-operation != ir_binop_mul) +continue; + + /* Multiply found on one of the operands. Now check for an + * inner addition operation. + */ + for (int inner_add_pos = 0; inner_add_pos 2; inner_add_pos++) { +ir_expression *inner_add = + mul-operands[inner_add_pos]-as_expression(); + +if (!inner_add || inner_add-operation != ir_binop_add) + continue; + +/* Inner addition found on one of the operands. Now check for + * one of the operands of the inner addition to be the negative + * of x_operand. + */ +for (int neg_pos = 0; neg_pos 2; neg_pos++) { + ir_expression *neg = + inner_add-operands[neg_pos]-as_expression(); + + if (!neg || neg-operation != ir_unop_neg) + continue; + + ir_rvalue *x_operand = ir-operands[1 - mul_pos]; + + if (!neg-operands[0]-equals(x_operand)) + continue; + + ir_rvalue *y_operand = inner_add-operands[1 - neg_pos]; + ir_rvalue *a_operand = mul-operands[1 - inner_add_pos]; + + if (x_operand-type != y_operand-type || + x_operand-type != a_operand-type) + continue; + + return lrp(x_operand, y_operand, a_operand); +} + } + } break; case ir_binop_sub: -- 1.8.3.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] i965: Use sample barycentric coordinates with per sample shading
Current implementation of arb_sample_shading doesn't set 'Barycentric Interpolation Mode' correctly. We use pixel barycentric coordinates for per sample shading. Instead we should select perspective sample or non-perspective sample barycentric coordinates. It also enables using sample barycentric coordinates in case of a fragment shader variable declared with 'sample' qualifier. e.g. sample in vec4 pos; A piglit test to verify the implementation has been posted on piglit mailing list for review. Signed-off-by: Anuj Phogat anuj.pho...@gmail.com Cc: Chris Forbes chr...@ijw.co.nz Cc: mesa-sta...@lists.freedesktop.org --- src/mesa/drivers/dri/i965/brw_fs.cpp | 13 ++--- src/mesa/drivers/dri/i965/brw_fs.h | 2 +- src/mesa/drivers/dri/i965/brw_wm.c | 18 -- src/mesa/drivers/dri/i965/brw_wm.h | 1 + 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index baf9220..a85646f 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -998,7 +998,7 @@ fs_visitor::emit_fragcoord_interpolation(ir_variable *ir) fs_inst * fs_visitor::emit_linterp(const fs_reg attr, const fs_reg interp, glsl_interp_qualifier interpolation_mode, - bool is_centroid) + bool is_centroid, bool is_sample) { brw_wm_barycentric_interp_mode barycoord_mode; if (brw-gen = 6) { @@ -1007,6 +1007,11 @@ fs_visitor::emit_linterp(const fs_reg attr, const fs_reg interp, barycoord_mode = BRW_WM_PERSPECTIVE_CENTROID_BARYCENTRIC; else barycoord_mode = BRW_WM_NONPERSPECTIVE_CENTROID_BARYCENTRIC; + } else if (is_sample) { + if (interpolation_mode == INTERP_QUALIFIER_SMOOTH) +barycoord_mode = BRW_WM_PERSPECTIVE_SAMPLE_BARYCENTRIC; + else +barycoord_mode = BRW_WM_NONPERSPECTIVE_SAMPLE_BARYCENTRIC; } else { if (interpolation_mode == INTERP_QUALIFIER_SMOOTH) barycoord_mode = BRW_WM_PERSPECTIVE_PIXEL_BARYCENTRIC; @@ -1084,7 +1089,8 @@ fs_visitor::emit_general_interpolation(ir_variable *ir) */ struct brw_reg interp = interp_reg(location, k); emit_linterp(attr, fs_reg(interp), interpolation_mode, -ir-data.centroid); +ir-data.centroid, +ir-data.sample || c-key.per_sample_shade); if (brw-needs_unlit_centroid_workaround ir-data.centroid) { /* Get the pixel/sample mask into f0 so that we know * which pixels are lit. Then, for each channel that is @@ -1093,7 +1099,8 @@ fs_visitor::emit_general_interpolation(ir_variable *ir) */ emit(FS_OPCODE_MOV_DISPATCH_TO_FLAGS); fs_inst *inst = emit_linterp(attr, fs_reg(interp), - interpolation_mode, false); + interpolation_mode, + false, false); inst-predicate = BRW_PREDICATE_NORMAL; inst-predicate_inverse = true; } diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h index 9bef07c..b5656bf 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.h +++ b/src/mesa/drivers/dri/i965/brw_fs.h @@ -336,7 +336,7 @@ public: fs_reg *emit_fragcoord_interpolation(ir_variable *ir); fs_inst *emit_linterp(const fs_reg attr, const fs_reg interp, glsl_interp_qualifier interpolation_mode, - bool is_centroid); + bool is_centroid, bool is_sample); fs_reg *emit_frontfacing_interpolation(ir_variable *ir); fs_reg *emit_samplepos_setup(ir_variable *ir); fs_reg *emit_sampleid_setup(ir_variable *ir); diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c index 6739a91..89830a4 100644 --- a/src/mesa/drivers/dri/i965/brw_wm.c +++ b/src/mesa/drivers/dri/i965/brw_wm.c @@ -52,6 +52,7 @@ brw_compute_barycentric_interp_modes(struct brw_context *brw, const struct gl_fragment_program *fprog) { unsigned barycentric_interp_modes = 0; + struct gl_context *ctx = brw-ctx; int attr; /* Loop through all fragment shader inputs to figure out what interpolation @@ -62,6 +63,8 @@ brw_compute_barycentric_interp_modes(struct brw_context *brw, enum glsl_interp_qualifier interp_qualifier = fprog-InterpQualifier[attr]; bool is_centroid = fprog-IsCentroid BITFIELD64_BIT(attr); + bool is_sample = (fprog-IsSample BITFIELD64_BIT(attr)) || + _mesa_get_min_invocations_per_fragment(ctx, fprog) 1; bool is_gl_Color = attr == VARYING_SLOT_COL0 || attr ==
Re: [Mesa-dev] [PATCH] glsl: Optimize open-coded lrp into lrp.
On Thu, Jan 9, 2014 at 2:37 PM, Jordan Justen jljus...@gmail.com wrote: On Thu, Jan 9, 2014 at 12:14 PM, Matt Turner matts...@gmail.com wrote: From: Jordan Justen jordan.l.jus...@intel.com total instructions in shared programs: 1498191 - 1487051 (-0.74%) instructions in affected programs: 669388 - 658248 (-1.66%) GAINED:1 LOST: 0 This is with the closed shader-db? I think the lost cases were L4D2. Yes. Could you retain my Signed-off-by? Yes, since I changed code I remove it. I'll add it to my queue of patches waiting to be committed. Feel free to hurry along the process by reviewing my 16 patch series from December. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] i965: Use sample barycentric coordinates with per sample shading
Hi Anuj, There's one fiddly interaction that I don't think this handles quite right, although I think it does conform. Suppose we have this fragment shader: #version 330 #extension ARB_gpu_shader5: require sample in vec4 a; in vec4 b; ... Then `b` is being evaluated at the sample position as well. This is allowed by my reading of the spec, but probably not what the author expected. From the ARB_gpu_shader5 spec, emphasis mine: (11) Should we support per-sample interpolation of attributes? If so, how? RESOLVED. Yes. When multisample rasterization is enabled, qualifying one or more fragment shader inputs with sample will force per-sample interpolation of those attributes. If the same shader includes other fragment inputs not qualified with sample, those attributes _may_ be interpolated per-pixel (i.e., all samples get the same values, likely evaluated at the pixel center). What do you think? -- Chris ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 2/2] i965: Fix clears of layered framebuffers with mismatched layer counts.
On Tue, Jan 7, 2014 at 7:33 AM, Paul Berry stereotype...@gmail.com wrote: Previously, Mesa enforced the following rule (from ARB_geometry_shader4's list of criteria for framebuffer completeness): * If any framebuffer attachment is layered, all attachments must have the same layer count. For three-dimensional textures, the layer count is the depth of the attached volume. For cube map textures, the layer count is always six. For one- and two-dimensional array textures, the layer count is simply the number of layers in the array texture. { FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB } However, when ARB_geometry_shader4 was adopted into GL 3.2, this rule was dropped; GL 3.2 permits different attachments to have different layer counts. This patch brings Mesa in line with GL 3.2. In order to ensure that layered clears properly clear all layers, we now have to keep track of the maximum number of layers in a layered framebuffer. Fixes the following piglit tests in spec/!OpenGL 3.2/layered-rendering: - clear-color-all-types 1d_array mipmapped - clear-color-all-types 1d_array single_level - clear-color-mismatched-layer-count - framebuffer-layer-count-mismatch --- src/mesa/drivers/common/meta.c | 4 ++-- src/mesa/drivers/dri/i965/brw_blorp_clear.cpp| 8 src/mesa/drivers/dri/i965/brw_clear.c| 6 +++--- src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 2 +- src/mesa/drivers/dri/i965/gen6_clip_state.c | 2 +- src/mesa/drivers/dri/i965/gen7_misc_state.c | 2 +- src/mesa/main/fbobject.c | 26 src/mesa/main/mtypes.h | 9 8 files changed, 29 insertions(+), 30 deletions(-) diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c index 7b41876..1294514 100644 --- a/src/mesa/drivers/common/meta.c +++ b/src/mesa/drivers/common/meta.c @@ -2407,9 +2407,9 @@ _mesa_meta_glsl_Clear(struct gl_context *ctx, GLbitfield buffers) GL_DYNAMIC_DRAW_ARB); /* draw quad(s) */ - if (fb-NumLayers 0) { + if (fb-MaxNumLayers 0) { unsigned layer; - for (layer = 0; layer fb-NumLayers; layer++) { + for (layer = 0; layer fb-MaxNumLayers; layer++) { if (fb-_IntegerColor) _mesa_Uniform1i(clear-IntegerLayerLocation, layer); else diff --git a/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp b/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp index 072ad55..c55108a 100644 --- a/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp +++ b/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp @@ -573,14 +573,14 @@ brw_blorp_clear_color(struct brw_context *brw, struct gl_framebuffer *fb, if (rb == NULL) continue; - if (fb-NumLayers 0) { + if (fb-MaxNumLayers 0) { unsigned layer_multiplier = (irb-mt-msaa_layout == INTEL_MSAA_LAYOUT_UMS || irb-mt-msaa_layout == INTEL_MSAA_LAYOUT_CMS) ? irb-mt-num_samples : 1; - assert(fb-NumLayers * layer_multiplier == -irb-mt-level[irb-mt_level].depth); - for (unsigned layer = 0; layer fb-NumLayers; layer++) { + unsigned num_layers = +irb-mt-level[irb-mt_level].depth / layer_multiplier; + for (unsigned layer = 0; layer num_layers; layer++) { if (!do_single_blorp_clear(brw, fb, rb, buf, partial_clear, layer * layer_multiplier)) { return false; diff --git a/src/mesa/drivers/dri/i965/brw_clear.c b/src/mesa/drivers/dri/i965/brw_clear.c index 1cac996..fe68d9e 100644 --- a/src/mesa/drivers/dri/i965/brw_clear.c +++ b/src/mesa/drivers/dri/i965/brw_clear.c @@ -181,9 +181,9 @@ brw_fast_clear_depth(struct gl_context *ctx) */ intel_batchbuffer_emit_mi_flush(brw); - if (fb-NumLayers 0) { - assert(fb-NumLayers == depth_irb-mt-level[depth_irb-mt_level].depth); - for (unsigned layer = 0; layer fb-NumLayers; layer++) { + if (fb-MaxNumLayers 0) { + unsigned num_layers = depth_irb-mt-level[depth_irb-mt_level].depth; + for (unsigned layer = 0; layer num_layers; layer++) { intel_hiz_exec(brw, mt, depth_irb-mt_level, layer, GEN6_HIZ_OP_DEPTH_CLEAR); } diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c index 5236eda..6bd4a29 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c @@ -700,7 +700,7 @@ brw_update_renderbuffer_surfaces(struct brw_context *brw) for (i = 0; i ctx-DrawBuffer-_NumColorDrawBuffers; i++) { if (intel_renderbuffer(ctx-DrawBuffer-_ColorDrawBuffers[i])) { brw-vtbl.update_renderbuffer_surface(brw, ctx-DrawBuffer-_ColorDrawBuffers[i], -
Re: [Mesa-dev] [PATCH 4/7] radeonsi: handle NULL colorbuffers correctly
On Don, 2014-01-09 at 13:05 +0100, Marek Olšák wrote: On Thu, Jan 9, 2014 at 3:51 AM, Michel Dänzer mic...@daenzer.net wrote: On Mit, 2014-01-08 at 18:23 +0100, Marek Olšák wrote: diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c index 3666a11..ba73401 100644 --- a/src/gallium/drivers/radeonsi/si_state.c +++ b/src/gallium/drivers/radeonsi/si_state.c [...] @@ -2136,16 +2143,11 @@ static void si_set_framebuffer_state(struct pipe_context *ctx, [...] si_set_msaa_state(rctx, pm4, nr_samples); rctx-fb_log_samples = util_logbase2(nr_samples); - rctx-fb_cb0_is_integer = state-nr_cbufs + rctx-fb_cb0_is_integer = state-nr_cbufs state-cbufs[0] util_format_is_pure_integer(state-cbufs[0]-format); Should this check the first non-NULL cbuf now instead of always cbufs[0]? fb_cb0_is_integer only affects alpha-to-one and alpha-to-coverage, which only use the first shader color output. Setting fb_cb0_is_integer=FALSE means that both can be enabled. The types of other colorbuffers don't matter. Thanks for the explanation, my Reviewed-by: stands then. :) -- Earthling Michel Dänzer| http://www.amd.com Libre software enthusiast |Mesa and X developer ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] glsl: Optimize open-coded lrp into lrp.
On Thu, Jan 9, 2014 at 4:27 PM, Matt Turner matts...@gmail.com wrote: On Thu, Jan 9, 2014 at 2:37 PM, Jordan Justen jljus...@gmail.com wrote: On Thu, Jan 9, 2014 at 12:14 PM, Matt Turner matts...@gmail.com wrote: From: Jordan Justen jordan.l.jus...@intel.com total instructions in shared programs: 1498191 - 1487051 (-0.74%) instructions in affected programs: 669388 - 658248 (-1.66%) GAINED:1 LOST: 0 This is with the closed shader-db? I think the lost cases were L4D2. Yes. Could you retain my Signed-off-by? Yes, since I changed code I remove it. I don't think that's a case for removing it. When I modify a patch, I usually add this below the old signatures: [email: frobbed stuffs] Signed-off-by: Email email I'll add it to my queue of patches waiting to be committed. Feel free to hurry along the process by reviewing my 16 patch series from December. :) Will do. -Jordan ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 2/2] i965: Fix clears of layered framebuffers with mismatched layer counts.
I'm not convinced this is correct/safe, at least for the meta clear. The GL 3.2 spec says, on page 221 (page 235 of the PDF): * If the number of layers of each attachment are not all identical, rendering will be limited to the smallest number of layers of any attachment. And then in the description of layered framebuffers on page 240 (page 254 of the PDF): If the fragment’s layer number is negative, or greater than the minimum number of layers of any attachment, the effects of the fragment on the framebuffer contents are undefined. Blorp clears can obviously do whatever they like, since they don't directly use the user's framebuffer configuration. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 01/30] mesa: Replace _mesa_program_index_to_target with _mesa_shader_stage_to_program.
In my recent zeal to refactor Mesa's handling of the gl_shader_stage enum, I accidentally wound up with two functions that do the same thing: _mesa_program_index_to_target(), and _mesa_shader_stage_to_program(). This patch keeps _mesa_shader_stage_to_program(), since its name is more consistent with other related functions. However, it changes the signature so that it accepts an unsigned integer instead of a gl_shader_stage--this avoids awkward casts when the function is called from C++ code. --- src/mesa/drivers/dri/i965/brw_shader.cpp | 2 +- src/mesa/program/ir_to_mesa.cpp| 2 +- src/mesa/program/program.h | 19 +-- src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 2 +- 4 files changed, 4 insertions(+), 21 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp b/src/mesa/drivers/dri/i965/brw_shader.cpp index cf9ca4b..141f8a4 100644 --- a/src/mesa/drivers/dri/i965/brw_shader.cpp +++ b/src/mesa/drivers/dri/i965/brw_shader.cpp @@ -127,7 +127,7 @@ brw_link_shader(struct gl_context *ctx, struct gl_shader_program *shProg) continue; struct gl_program *prog = -ctx-Driver.NewProgram(ctx, _mesa_program_index_to_target(stage), +ctx-Driver.NewProgram(ctx, _mesa_shader_stage_to_program(stage), shader-base.Name); if (!prog) return false; diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index f6c229c..af6f59f 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -3053,7 +3053,7 @@ _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog) _mesa_reference_program(ctx, prog-_LinkedShaders[i]-Program, linked_prog); if (!ctx-Driver.ProgramStringNotify(ctx, - _mesa_program_index_to_target(i), + _mesa_shader_stage_to_program(i), linked_prog)) { return GL_FALSE; } diff --git a/src/mesa/program/program.h b/src/mesa/program/program.h index 0e350cd..f666e30 100644 --- a/src/mesa/program/program.h +++ b/src/mesa/program/program.h @@ -209,7 +209,7 @@ _mesa_program_enum_to_shader_stage(GLenum v) static inline GLenum -_mesa_shader_stage_to_program(gl_shader_stage stage) +_mesa_shader_stage_to_program(unsigned stage) { switch (stage) { case MESA_SHADER_VERTEX: @@ -225,23 +225,6 @@ _mesa_shader_stage_to_program(gl_shader_stage stage) } -static inline GLenum -_mesa_program_index_to_target(GLuint i) -{ - static const GLenum enums[] = { - GL_VERTEX_PROGRAM_ARB, - GL_GEOMETRY_PROGRAM_NV, - GL_FRAGMENT_PROGRAM_ARB - }; - STATIC_ASSERT(Elements(enums) == MESA_SHADER_STAGES); - if(i = MESA_SHADER_STAGES) { - assert(!Unexpected program index); - return 0; - } else - return enums[i]; -} - - /* Cast wrappers from gl_program to gl_vertex/geometry/fragment_program */ static inline struct gl_fragment_program * diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index 73c39eb..a7dfa67 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -5319,7 +5319,7 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog) _mesa_reference_program(ctx, prog-_LinkedShaders[i]-Program, linked_prog); if (!ctx-Driver.ProgramStringNotify(ctx, - _mesa_program_index_to_target(i), + _mesa_shader_stage_to_program(i), linked_prog)) { _mesa_reference_program(ctx, prog-_LinkedShaders[i]-Program, NULL); -- 1.8.5.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 03/30] main: Allow ctx == NULL in _mesa_validate_shader_target().
This will allow this function to be used in circumstances where there is no context available, such as when building built-in GLSL functions. --- src/mesa/main/shaderapi.c | 13 ++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index 716e659..2ab0a0c 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -174,13 +174,20 @@ _mesa_copy_string(GLchar *dst, GLsizei maxLength, bool _mesa_validate_shader_target(const struct gl_context *ctx, GLenum type) { + /* Note: when building built-in GLSL functions, this function may be +* invoked with ctx == NULL. In that case, we can only validate that it's +* a shader target we recognize, not that it's supported in the current +* context. But that's fine--we don't need any further validation than +* that when building built-in GLSL functions. +*/ + switch (type) { case GL_FRAGMENT_SHADER: - return ctx-Extensions.ARB_fragment_shader; + return ctx == NULL || ctx-Extensions.ARB_fragment_shader; case GL_VERTEX_SHADER: - return ctx-Extensions.ARB_vertex_shader; + return ctx == NULL || ctx-Extensions.ARB_vertex_shader; case GL_GEOMETRY_SHADER_ARB: - return _mesa_has_geometry_shaders(ctx); + return ctx == NULL || _mesa_has_geometry_shaders(ctx); default: return false; } -- 1.8.5.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 02/30] mesa: Make validate_shader_target() non-static.
--- src/mesa/main/shaderapi.c | 8 src/mesa/main/shaderapi.h | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index 6042fa8..716e659 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -171,8 +171,8 @@ _mesa_copy_string(GLchar *dst, GLsizei maxLength, * \param type Shader target * */ -static bool -validate_shader_target(const struct gl_context *ctx, GLenum type) +bool +_mesa_validate_shader_target(const struct gl_context *ctx, GLenum type) { switch (type) { case GL_FRAGMENT_SHADER: @@ -273,7 +273,7 @@ create_shader(struct gl_context *ctx, GLenum type) struct gl_shader *sh; GLuint name; - if (!validate_shader_target(ctx, type)) { + if (!_mesa_validate_shader_target(ctx, type)) { _mesa_error(ctx, GL_INVALID_ENUM, CreateShader(type)); return 0; } @@ -1739,7 +1739,7 @@ _mesa_UseShaderProgramEXT(GLenum type, GLuint program) GET_CURRENT_CONTEXT(ctx); struct gl_shader_program *shProg = NULL; - if (!validate_shader_target(ctx, type)) { + if (!_mesa_validate_shader_target(ctx, type)) { _mesa_error(ctx, GL_INVALID_ENUM, glUseShaderProgramEXT(type)); return; } diff --git a/src/mesa/main/shaderapi.h b/src/mesa/main/shaderapi.h index 4822e32..10f810c 100644 --- a/src/mesa/main/shaderapi.h +++ b/src/mesa/main/shaderapi.h @@ -215,6 +215,9 @@ _mesa_copy_linked_program_data(gl_shader_stage type, const struct gl_shader_program *src, struct gl_program *dst); +extern bool +_mesa_validate_shader_target(const struct gl_context *ctx, GLenum type); + #ifdef __cplusplus } -- 1.8.5.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 10/30] mesa: Remove ad-hoc arrays of gl_shader_program.
Now that we have a ctx-Shader.CurrentProgram array, we can just use it directly. --- src/mesa/main/context.c | 6 +- src/mesa/state_tracker/st_draw.c| 6 +- src/mesa/state_tracker/st_program.c | 6 +- 3 files changed, 3 insertions(+), 15 deletions(-) diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 026d7aa..5855f15 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1853,13 +1853,9 @@ _mesa_valid_to_render(struct gl_context *ctx, const char *where) #ifdef DEBUG if (ctx-Shader.Flags GLSL_LOG) { - struct gl_shader_program *shProg[MESA_SHADER_STAGES]; + struct gl_shader_program **shProg = ctx-Shader.CurrentProgram; gl_shader_stage i; - shProg[MESA_SHADER_VERTEX] = ctx-Shader.CurrentProgram[MESA_SHADER_VERTEX]; - shProg[MESA_SHADER_GEOMETRY] = ctx-Shader.CurrentProgram[MESA_SHADER_GEOMETRY]; - shProg[MESA_SHADER_FRAGMENT] = ctx-Shader.CurrentProgram[MESA_SHADER_FRAGMENT]; - for (i = 0; i MESA_SHADER_STAGES; i++) { if (shProg[i] == NULL || shProg[i]-_Used || shProg[i]-_LinkedShaders[i] == NULL) diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 75a71f1..85677c3 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -131,11 +131,7 @@ setup_index_buffer(struct st_context *st, static void check_uniforms(struct gl_context *ctx) { - struct gl_shader_program *shProg[3] = { - ctx-Shader.CurrentProgram[MESA_SHADER_VERTEX], - ctx-Shader.CurrentProgram[MESA_SHADER_GEOMETRY], - ctx-Shader.CurrentProgram[MESA_SHADER_FRAGMENT], - }; + struct gl_shader_program **shProg = ctx-Shader.CurrentProgram; unsigned j; for (j = 0; j 3; j++) { diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index fe3dafe..ef2abdb 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -1195,11 +1195,7 @@ st_get_gp_variant(struct st_context *st, void st_print_shaders(struct gl_context *ctx) { - struct gl_shader_program *shProg[3] = { - ctx-Shader.CurrentProgram[MESA_SHADER_VERTEX], - ctx-Shader.CurrentProgram[MESA_SHADER_GEOMETRY], - ctx-Shader.CurrentProgram[MESA_SHADER_FRAGMENT], - }; + struct gl_shader_program **shProg = ctx-Shader.CurrentProgram; unsigned j; for (j = 0; j 3; j++) { -- 1.8.5.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 08/30] i965: Fix comments to refer to the new ctx-Shader.CurrentProgram array.
--- src/mesa/drivers/dri/i965/brw_wm_state.c | 4 ++-- src/mesa/drivers/dri/i965/gen6_wm_state.c | 4 ++-- src/mesa/drivers/dri/i965/gen7_wm_state.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_wm_state.c b/src/mesa/drivers/dri/i965/brw_wm_state.c index 303a2eb..514dfb2 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_state.c @@ -112,8 +112,8 @@ brw_upload_wm_unit(struct brw_context *brw) wm-thread1.depth_coef_urb_read_offset = 1; /* Use ALT floating point mode for ARB fragment programs, because they * require 0^0 == 1. Even though _CurrentFragmentProgram is used for -* rendering, CurrentFragmentProgram is used for this check to -* differentiate between the GLSL and non-GLSL cases. +* rendering, CurrentProgram[MESA_SHADER_FRAGMENT] is used for this check +* to differentiate between the GLSL and non-GLSL cases. */ if (ctx-Shader.CurrentProgram[MESA_SHADER_FRAGMENT] == NULL) wm-thread1.floating_point_mode = BRW_FLOATING_POINT_NON_IEEE_754; diff --git a/src/mesa/drivers/dri/i965/gen6_wm_state.c b/src/mesa/drivers/dri/i965/gen6_wm_state.c index 5188aa8..585c0c5 100644 --- a/src/mesa/drivers/dri/i965/gen6_wm_state.c +++ b/src/mesa/drivers/dri/i965/gen6_wm_state.c @@ -137,8 +137,8 @@ upload_wm_state(struct brw_context *brw) /* Use ALT floating point mode for ARB fragment programs, because they * require 0^0 == 1. Even though _CurrentFragmentProgram is used for -* rendering, CurrentFragmentProgram is used for this check to -* differentiate between the GLSL and non-GLSL cases. +* rendering, CurrentProgram[MESA_SHADER_FRAGMENT] is used for this check +* to differentiate between the GLSL and non-GLSL cases. */ if (ctx-Shader.CurrentProgram[MESA_SHADER_FRAGMENT] == NULL) dw2 |= GEN6_WM_FLOATING_POINT_MODE_ALT; diff --git a/src/mesa/drivers/dri/i965/gen7_wm_state.c b/src/mesa/drivers/dri/i965/gen7_wm_state.c index 7f2a50c..284f8b6 100644 --- a/src/mesa/drivers/dri/i965/gen7_wm_state.c +++ b/src/mesa/drivers/dri/i965/gen7_wm_state.c @@ -170,8 +170,8 @@ upload_ps_state(struct brw_context *brw) /* Use ALT floating point mode for ARB fragment programs, because they * require 0^0 == 1. Even though _CurrentFragmentProgram is used for -* rendering, CurrentFragmentProgram is used for this check to -* differentiate between the GLSL and non-GLSL cases. +* rendering, CurrentProgram[MESA_SHADER_FRAGMENT] is used for this check +* to differentiate between the GLSL and non-GLSL cases. */ /* BRW_NEW_FRAGMENT_PROGRAM */ if (ctx-Shader.CurrentProgram[MESA_SHADER_FRAGMENT] == NULL) -- 1.8.5.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 15/30] glsl/cs: Change some linker loops to use MESA_SHADER_FRAGMENT as a bound.
Linker loops that iterate through all the stages in the pipeline need to use MESA_SHADER_FRAGMENT as a bound, so that we can add an additional MESA_SHADER_COMPUTE stage, without it being erroneously included in the pipeline. --- src/glsl/linker.cpp | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index f3fd66f..7461b17 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -2094,7 +2094,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog) unsigned prev; - for (prev = 0; prev MESA_SHADER_STAGES; prev++) { + for (prev = 0; prev = MESA_SHADER_FRAGMENT; prev++) { if (prog-_LinkedShaders[prev] != NULL) break; } @@ -2102,7 +2102,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog) /* Validate the inputs of each stage with the output of the preceding * stage. */ - for (unsigned i = prev + 1; i MESA_SHADER_STAGES; i++) { + for (unsigned i = prev + 1; i = MESA_SHADER_FRAGMENT; i++) { if (prog-_LinkedShaders[i] == NULL) continue; @@ -2197,7 +2197,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog) } unsigned first; - for (first = 0; first MESA_SHADER_STAGES; first++) { + for (first = 0; first = MESA_SHADER_FRAGMENT; first++) { if (prog-_LinkedShaders[first] != NULL) break; } @@ -2229,7 +2229,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog) * eliminated if they are (transitively) not used in a later stage. */ int last, next; - for (last = MESA_SHADER_STAGES-1; last = 0; last--) { + for (last = MESA_SHADER_FRAGMENT; last = 0; last--) { if (prog-_LinkedShaders[last] != NULL) break; } -- 1.8.5.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 05/30] glsl/linker: Refactor in preparation for adding more shader stages.
Rather than maintain separately named arrays and counts for vertex, geometry, and fragment shaders, just maintain these as arrays indexed by the gl_shader_type enum. --- src/glsl/linker.cpp | 114 ++-- 1 file changed, 39 insertions(+), 75 deletions(-) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index e820f0f..f3fd66f 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -1994,19 +1994,14 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog) /* Separate the shaders into groups based on their type. */ - struct gl_shader **vert_shader_list; - unsigned num_vert_shaders = 0; - struct gl_shader **frag_shader_list; - unsigned num_frag_shaders = 0; - struct gl_shader **geom_shader_list; - unsigned num_geom_shaders = 0; - - vert_shader_list = (struct gl_shader **) - calloc(prog-NumShaders, sizeof(struct gl_shader *)); - frag_shader_list = (struct gl_shader **) - calloc(prog-NumShaders, sizeof(struct gl_shader *)); - geom_shader_list = (struct gl_shader **) - calloc(prog-NumShaders, sizeof(struct gl_shader *)); + struct gl_shader **shader_list[MESA_SHADER_STAGES]; + unsigned num_shaders[MESA_SHADER_STAGES]; + + for (int i = 0; i MESA_SHADER_STAGES; i++) { + shader_list[i] = (struct gl_shader **) + calloc(prog-NumShaders, sizeof(struct gl_shader *)); + num_shaders[i] = 0; + } unsigned min_version = UINT_MAX; unsigned max_version = 0; @@ -2022,20 +2017,9 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog) goto done; } - switch (prog-Shaders[i]-Stage) { - case MESA_SHADER_VERTEX: -vert_shader_list[num_vert_shaders] = prog-Shaders[i]; -num_vert_shaders++; -break; - case MESA_SHADER_FRAGMENT: -frag_shader_list[num_frag_shaders] = prog-Shaders[i]; -num_frag_shaders++; -break; - case MESA_SHADER_GEOMETRY: -geom_shader_list[num_geom_shaders] = prog-Shaders[i]; -num_geom_shaders++; -break; - } + gl_shader_stage shader_type = prog-Shaders[i]-Stage; + shader_list[shader_type][num_shaders[shader_type]] = prog-Shaders[i]; + num_shaders[shader_type]++; } /* In desktop GLSL, different shader versions may be linked together. In @@ -2052,7 +2036,8 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog) /* Geometry shaders have to be linked with vertex shaders. */ - if (num_geom_shaders 0 num_vert_shaders == 0) { + if (num_shaders[MESA_SHADER_GEOMETRY] 0 + num_shaders[MESA_SHADER_VERTEX] == 0) { linker_error(prog, Geometry shader must be linked with vertex shader\n); goto done; @@ -2067,55 +2052,37 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog) /* Link all shaders for a particular stage and validate the result. */ - if (num_vert_shaders 0) { - gl_shader *const sh = -link_intrastage_shaders(mem_ctx, ctx, prog, vert_shader_list, -num_vert_shaders); - - if (!prog-LinkStatus) -goto done; - - validate_vertex_shader_executable(prog, sh); - if (!prog-LinkStatus) -goto done; - prog-LastClipDistanceArraySize = prog-Vert.ClipDistanceArraySize; + for (int stage = 0; stage MESA_SHADER_STAGES; stage++) { + if (num_shaders[stage] 0) { + gl_shader *const sh = +link_intrastage_shaders(mem_ctx, ctx, prog, shader_list[stage], +num_shaders[stage]); - _mesa_reference_shader(ctx, prog-_LinkedShaders[MESA_SHADER_VERTEX], -sh); - } - - if (num_frag_shaders 0) { - gl_shader *const sh = -link_intrastage_shaders(mem_ctx, ctx, prog, frag_shader_list, -num_frag_shaders); - - if (!prog-LinkStatus) -goto done; + if (!prog-LinkStatus) +goto done; - validate_fragment_shader_executable(prog, sh); - if (!prog-LinkStatus) -goto done; + switch (stage) { + case MESA_SHADER_VERTEX: +validate_vertex_shader_executable(prog, sh); +break; + case MESA_SHADER_GEOMETRY: +validate_geometry_shader_executable(prog, sh); +break; + case MESA_SHADER_FRAGMENT: +validate_fragment_shader_executable(prog, sh); +break; + } + if (!prog-LinkStatus) +goto done; - _mesa_reference_shader(ctx, prog-_LinkedShaders[MESA_SHADER_FRAGMENT], -sh); + _mesa_reference_shader(ctx, prog-_LinkedShaders[stage], sh); + } } - if (num_geom_shaders 0) { - gl_shader *const sh = -link_intrastage_shaders(mem_ctx, ctx, prog, geom_shader_list, -num_geom_shaders); - -
[Mesa-dev] [PATCH 07/30] mesa: Fold long lines introduced by the previous patch.
--- src/mesa/drivers/dri/i965/brw_gs_surface_state.c | 6 -- src/mesa/drivers/dri/i965/brw_vec4_gs.c | 5 +++-- src/mesa/drivers/dri/i965/brw_vs.c | 5 +++-- src/mesa/drivers/dri/i965/brw_vs_surface_state.c | 6 -- src/mesa/main/context.c | 6 -- src/mesa/main/state.c| 9 ++--- src/mesa/main/transformfeedback.c| 3 ++- src/mesa/state_tracker/st_atom_constbuf.c| 9 ++--- 8 files changed, 32 insertions(+), 17 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_gs_surface_state.c b/src/mesa/drivers/dri/i965/brw_gs_surface_state.c index 1ccf2e2..0795e56 100644 --- a/src/mesa/drivers/dri/i965/brw_gs_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_gs_surface_state.c @@ -69,7 +69,8 @@ brw_upload_gs_ubo_surfaces(struct brw_context *brw) struct gl_context *ctx = brw-ctx; /* _NEW_PROGRAM */ - struct gl_shader_program *prog = ctx-Shader.CurrentProgram[MESA_SHADER_GEOMETRY]; + struct gl_shader_program *prog = + ctx-Shader.CurrentProgram[MESA_SHADER_GEOMETRY]; if (!prog) return; @@ -93,7 +94,8 @@ brw_upload_gs_abo_surfaces(struct brw_context *brw) { struct gl_context *ctx = brw-ctx; /* _NEW_PROGRAM */ - struct gl_shader_program *prog = ctx-Shader.CurrentProgram[MESA_SHADER_GEOMETRY]; + struct gl_shader_program *prog = + ctx-Shader.CurrentProgram[MESA_SHADER_GEOMETRY]; if (prog) { /* CACHE_NEW_GS_PROG */ diff --git a/src/mesa/drivers/dri/i965/brw_vec4_gs.c b/src/mesa/drivers/dri/i965/brw_vec4_gs.c index 7a803cb..e2a4a38 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_gs.c +++ b/src/mesa/drivers/dri/i965/brw_vec4_gs.c @@ -290,8 +290,9 @@ brw_upload_gs_prog(struct brw_context *brw) if (!brw_search_cache(brw-cache, BRW_GS_PROG, key, sizeof(key), stage_state-prog_offset, brw-gs.prog_data)) { - bool success = do_gs_prog(brw, ctx-Shader.CurrentProgram[MESA_SHADER_GEOMETRY], -gp, key); + bool success = + do_gs_prog(brw, ctx-Shader.CurrentProgram[MESA_SHADER_GEOMETRY], gp, +key); assert(success); } brw-gs.base.prog_data = brw-gs.prog_data-base.base; diff --git a/src/mesa/drivers/dri/i965/brw_vs.c b/src/mesa/drivers/dri/i965/brw_vs.c index 351a83e..971b2d1 100644 --- a/src/mesa/drivers/dri/i965/brw_vs.c +++ b/src/mesa/drivers/dri/i965/brw_vs.c @@ -481,8 +481,9 @@ static void brw_upload_vs_prog(struct brw_context *brw) if (!brw_search_cache(brw-cache, BRW_VS_PROG, key, sizeof(key), brw-vs.base.prog_offset, brw-vs.prog_data)) { - bool success = do_vs_prog(brw, ctx-Shader.CurrentProgram[MESA_SHADER_VERTEX], - vp, key); + bool success = + do_vs_prog(brw, ctx-Shader.CurrentProgram[MESA_SHADER_VERTEX], vp, +key); (void) success; assert(success); } diff --git a/src/mesa/drivers/dri/i965/brw_vs_surface_state.c b/src/mesa/drivers/dri/i965/brw_vs_surface_state.c index 2fbcdf9..e707d32 100644 --- a/src/mesa/drivers/dri/i965/brw_vs_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_vs_surface_state.c @@ -130,7 +130,8 @@ brw_upload_vs_ubo_surfaces(struct brw_context *brw) { struct gl_context *ctx = brw-ctx; /* _NEW_PROGRAM */ - struct gl_shader_program *prog = ctx-Shader.CurrentProgram[MESA_SHADER_VERTEX]; + struct gl_shader_program *prog = + ctx-Shader.CurrentProgram[MESA_SHADER_VERTEX]; if (!prog) return; @@ -154,7 +155,8 @@ brw_upload_vs_abo_surfaces(struct brw_context *brw) { struct gl_context *ctx = brw-ctx; /* _NEW_PROGRAM */ - struct gl_shader_program *prog = ctx-Shader.CurrentProgram[MESA_SHADER_VERTEX]; + struct gl_shader_program *prog = + ctx-Shader.CurrentProgram[MESA_SHADER_VERTEX]; if (prog) { /* CACHE_NEW_VS_PROG */ diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 8e978eb..026d7aa 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1780,7 +1780,8 @@ _mesa_valid_to_render(struct gl_context *ctx, const char *where) ctx-Shader.CurrentProgram[MESA_SHADER_GEOMETRY], errMsg)) { _mesa_warning(ctx, Shader program %u is invalid: %s, - ctx-Shader.CurrentProgram[MESA_SHADER_GEOMETRY]-Name, errMsg); + ctx-Shader.CurrentProgram[MESA_SHADER_GEOMETRY]-Name, + errMsg); } } #endif @@ -1801,7 +1802,8 @@ _mesa_valid_to_render(struct gl_context *ctx, const char *where) ctx-Shader.CurrentProgram[MESA_SHADER_FRAGMENT], errMsg)) { _mesa_warning(ctx, Shader program %u is
[Mesa-dev] [PATCH 18/30] glsl/cs: update main.cpp to use the .comp extension for compute shaders.
--- src/glsl/main.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp index afc15cb..864c929 100644 --- a/src/glsl/main.cpp +++ b/src/glsl/main.cpp @@ -364,6 +364,8 @@ main(int argc, char **argv) shader-Type = GL_GEOMETRY_SHADER; else if (strncmp(.frag, ext, 5) == 0) shader-Type = GL_FRAGMENT_SHADER; + else if (strncmp(.comp, ext, 5) == 0) + shader-Type = GL_COMPUTE_SHADER; else usage_fail(argv[0]); shader-Stage = _mesa_shader_enum_to_shader_stage(shader-Type); -- 1.8.5.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 06/30] mesa: Replace ctx-Shader.Current{Vertex, Fragment, Geometry}Program with an array.
These are replaced with ctx-Shader.CurrentProgram[MESA_SHADER_{VERTEX,FRAGMENT,GEOMETRY}]. In patches to follow, this will allow us to replace a lot of ad-hoc logic with a variable index into the array. With the exception of the changes to mtypes.h, this patch was generated entirely by the command: find src -type f '(' -iname '*.c' -o -iname '*.cpp' ')' \ -print0 | xargs -0 sed -i \ -e 's/\.CurrentVertexProgram/.CurrentProgram[MESA_SHADER_VERTEX]/g' \ -e 's/\.CurrentGeometryProgram/.CurrentProgram[MESA_SHADER_GEOMETRY]/g' \ -e 's/\.CurrentFragmentProgram/.CurrentProgram[MESA_SHADER_FRAGMENT]/g' --- src/mesa/drivers/common/meta.c | 6 ++--- src/mesa/drivers/dri/i965/brw_gs.c | 2 +- src/mesa/drivers/dri/i965/brw_gs_surface_state.c | 4 ++-- src/mesa/drivers/dri/i965/brw_vec4_gs.c | 2 +- src/mesa/drivers/dri/i965/brw_vs.c | 4 ++-- src/mesa/drivers/dri/i965/brw_vs_state.c | 2 +- src/mesa/drivers/dri/i965/brw_vs_surface_state.c | 4 ++-- src/mesa/drivers/dri/i965/brw_wm_state.c | 2 +- src/mesa/drivers/dri/i965/gen6_sol.c | 6 ++--- src/mesa/drivers/dri/i965/gen6_vs_state.c| 2 +- src/mesa/drivers/dri/i965/gen6_wm_state.c| 2 +- src/mesa/drivers/dri/i965/gen7_sol_state.c | 4 ++-- src/mesa/drivers/dri/i965/gen7_vs_state.c| 2 +- src/mesa/drivers/dri/i965/gen7_wm_state.c| 2 +- src/mesa/main/api_validate.c | 10 src/mesa/main/context.c | 30 src/mesa/main/ff_fragment_shader.cpp | 8 +++ src/mesa/main/mtypes.h | 7 +++--- src/mesa/main/shaderapi.c| 12 +- src/mesa/main/state.c| 8 +++ src/mesa/main/texstate.c | 18 +++--- src/mesa/main/transformfeedback.c| 8 +++ src/mesa/state_tracker/st_atom_clip.c| 2 +- src/mesa/state_tracker/st_atom_constbuf.c| 6 ++--- src/mesa/state_tracker/st_cb_drawpixels.c| 2 +- src/mesa/state_tracker/st_draw.c | 6 ++--- src/mesa/state_tracker/st_program.c | 6 ++--- src/mesa/swrast/s_fragprog.c | 2 +- 28 files changed, 84 insertions(+), 85 deletions(-) diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c index 7b41876..5643e3c 100644 --- a/src/mesa/drivers/common/meta.c +++ b/src/mesa/drivers/common/meta.c @@ -618,11 +618,11 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state) } _mesa_reference_shader_program(ctx, save-VertexShader, - ctx-Shader.CurrentVertexProgram); + ctx-Shader.CurrentProgram[MESA_SHADER_VERTEX]); _mesa_reference_shader_program(ctx, save-GeometryShader, - ctx-Shader.CurrentGeometryProgram); + ctx-Shader.CurrentProgram[MESA_SHADER_GEOMETRY]); _mesa_reference_shader_program(ctx, save-FragmentShader, - ctx-Shader.CurrentFragmentProgram); + ctx-Shader.CurrentProgram[MESA_SHADER_FRAGMENT]); _mesa_reference_shader_program(ctx, save-ActiveShader, ctx-Shader.ActiveProgram); diff --git a/src/mesa/drivers/dri/i965/brw_gs.c b/src/mesa/drivers/dri/i965/brw_gs.c index faa8f94..1ba26de 100644 --- a/src/mesa/drivers/dri/i965/brw_gs.c +++ b/src/mesa/drivers/dri/i965/brw_gs.c @@ -187,7 +187,7 @@ static void populate_key(struct brw_context *brw, /* BRW_NEW_TRANSFORM_FEEDBACK */ if (_mesa_is_xfb_active_and_unpaused(ctx)) { const struct gl_shader_program *shaderprog = -ctx-Shader.CurrentVertexProgram; +ctx-Shader.CurrentProgram[MESA_SHADER_VERTEX]; const struct gl_transform_feedback_info *linked_xfb_info = shaderprog-LinkedTransformFeedback; int i; diff --git a/src/mesa/drivers/dri/i965/brw_gs_surface_state.c b/src/mesa/drivers/dri/i965/brw_gs_surface_state.c index 5661941..1ccf2e2 100644 --- a/src/mesa/drivers/dri/i965/brw_gs_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_gs_surface_state.c @@ -69,7 +69,7 @@ brw_upload_gs_ubo_surfaces(struct brw_context *brw) struct gl_context *ctx = brw-ctx; /* _NEW_PROGRAM */ - struct gl_shader_program *prog = ctx-Shader.CurrentGeometryProgram; + struct gl_shader_program *prog = ctx-Shader.CurrentProgram[MESA_SHADER_GEOMETRY]; if (!prog) return; @@ -93,7 +93,7 @@ brw_upload_gs_abo_surfaces(struct brw_context *brw) { struct gl_context *ctx = brw-ctx; /* _NEW_PROGRAM */ - struct gl_shader_program *prog = ctx-Shader.CurrentGeometryProgram; + struct gl_shader_program *prog =
[Mesa-dev] [PATCH 20/30] mesa/cs: Create the gl_compute_program struct, and the code to initialize it.
--- src/mesa/main/mtypes.h | 7 +++ src/mesa/program/program.c | 20 src/mesa/program/program.h | 5 + 3 files changed, 32 insertions(+) diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 8b88d75..e6c3a22 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2167,6 +2167,13 @@ struct gl_fragment_program }; +/** Compute program object */ +struct gl_compute_program +{ + struct gl_program Base; /** base class */ +}; + + /** * State common to vertex and fragment programs. */ diff --git a/src/mesa/program/program.c b/src/mesa/program/program.c index 3c19e8c..d21bfa0 100644 --- a/src/mesa/program/program.c +++ b/src/mesa/program/program.c @@ -279,6 +279,21 @@ _mesa_init_vertex_program( struct gl_context *ctx, struct gl_vertex_program *pro /** + * Initialize a new compute program object. + */ +struct gl_program * +_mesa_init_compute_program(struct gl_context *ctx, + struct gl_compute_program *prog, GLenum target, + GLuint id) +{ + if (prog) + return _mesa_init_program_struct( ctx, prog-Base, target, id ); + else + return NULL; +} + + +/** * Initialize a new geometry program object. */ struct gl_program * @@ -324,6 +339,11 @@ _mesa_new_program(struct gl_context *ctx, GLenum target, GLuint id) CALLOC_STRUCT(gl_geometry_program), target, id); break; + case GL_COMPUTE_PROGRAM_NV: + prog = _mesa_init_compute_program(ctx, +CALLOC_STRUCT(gl_compute_program), +target, id); + break; default: _mesa_problem(ctx, bad target in _mesa_new_program); prog = NULL; diff --git a/src/mesa/program/program.h b/src/mesa/program/program.h index 84aa8cb..cab7d71 100644 --- a/src/mesa/program/program.h +++ b/src/mesa/program/program.h @@ -84,6 +84,11 @@ _mesa_init_geometry_program(struct gl_context *ctx, GLenum target, GLuint id); extern struct gl_program * +_mesa_init_compute_program(struct gl_context *ctx, + struct gl_compute_program *prog, + GLenum target, GLuint id); + +extern struct gl_program * _mesa_new_program(struct gl_context *ctx, GLenum target, GLuint id); extern void -- 1.8.5.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 12/30] mesa: Change redundant code into loops in texstate.c.
This is possible now that ctx-Shader.CurrentProgram is an array. --- src/mesa/main/texstate.c | 75 +++- 1 file changed, 29 insertions(+), 46 deletions(-) diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c index b9c76da..905a9d5 100644 --- a/src/mesa/main/texstate.c +++ b/src/mesa/main/texstate.c @@ -526,27 +526,20 @@ static void update_texture_state( struct gl_context *ctx ) { GLuint unit; - struct gl_program *fprog = NULL; - struct gl_program *vprog = NULL; - struct gl_program *gprog = NULL; + struct gl_program *prog[MESA_SHADER_STAGES]; GLbitfield enabledFragUnits = 0x0; - - if (ctx-Shader.CurrentProgram[MESA_SHADER_VERTEX] - ctx-Shader.CurrentProgram[MESA_SHADER_VERTEX]-LinkStatus) { - vprog = ctx-Shader.CurrentProgram[MESA_SHADER_VERTEX]-_LinkedShaders[MESA_SHADER_VERTEX]-Program; - } - - if (ctx-Shader.CurrentProgram[MESA_SHADER_GEOMETRY] - ctx-Shader.CurrentProgram[MESA_SHADER_GEOMETRY]-LinkStatus) { - gprog = ctx-Shader.CurrentProgram[MESA_SHADER_GEOMETRY]-_LinkedShaders[MESA_SHADER_GEOMETRY]-Program; - } - - if (ctx-Shader.CurrentProgram[MESA_SHADER_FRAGMENT] - ctx-Shader.CurrentProgram[MESA_SHADER_FRAGMENT]-LinkStatus) { - fprog = ctx-Shader.CurrentProgram[MESA_SHADER_FRAGMENT]-_LinkedShaders[MESA_SHADER_FRAGMENT]-Program; - } - else if (ctx-FragmentProgram._Enabled) { - fprog = ctx-FragmentProgram.Current-Base; + int i; + + for (i = 0; i MESA_SHADER_STAGES; i++) { + if (ctx-Shader.CurrentProgram[i] + ctx-Shader.CurrentProgram[i]-LinkStatus) { + prog[i] = ctx-Shader.CurrentProgram[i]-_LinkedShaders[i]-Program; + } else { + if (i == MESA_SHADER_FRAGMENT ctx-FragmentProgram._Enabled) +prog[i] = ctx-FragmentProgram.Current-Base; + else +prog[i] = NULL; + } } /* TODO: only set this if there are actual changes */ @@ -562,9 +555,7 @@ update_texture_state( struct gl_context *ctx ) */ for (unit = 0; unit ctx-Const.MaxCombinedTextureImageUnits; unit++) { struct gl_texture_unit *texUnit = ctx-Texture.Unit[unit]; - GLbitfield enabledVertTargets = 0x0; - GLbitfield enabledFragTargets = 0x0; - GLbitfield enabledGeomTargets = 0x0; + GLbitfield enabledTargetsByStage[MESA_SHADER_STAGES]; GLbitfield enabledTargets = 0x0; GLuint texIndex; @@ -574,25 +565,16 @@ update_texture_state( struct gl_context *ctx ) * by a fragment program/program. When multiple flags are set, we'll * settle on the one with highest priority (see below). */ - if (vprog) { - enabledVertTargets |= vprog-TexturesUsed[unit]; + for (i = 0; i MESA_SHADER_STAGES; i++) { + if (prog[i]) +enabledTargetsByStage[i] = prog[i]-TexturesUsed[unit]; + else if (i == MESA_SHADER_FRAGMENT) +enabledTargetsByStage[i] = texUnit-Enabled; + else +enabledTargetsByStage[i] = 0; + enabledTargets |= enabledTargetsByStage[i]; } - if (gprog) { - enabledGeomTargets |= gprog-TexturesUsed[unit]; - } - - if (fprog) { - enabledFragTargets |= fprog-TexturesUsed[unit]; - } - else { - /* fixed-function fragment program */ - enabledFragTargets |= texUnit-Enabled; - } - - enabledTargets = enabledVertTargets | enabledFragTargets | - enabledGeomTargets; - texUnit-_ReallyEnabled = 0x0; if (enabledTargets == 0x0) { @@ -624,7 +606,7 @@ update_texture_state( struct gl_context *ctx ) } if (!texUnit-_ReallyEnabled) { - if (fprog) { + if (prog[MESA_SHADER_FRAGMENT]) { /* If we get here it means the shader is expecting a texture * object, but there isn't one (or it's incomplete). Use the * fallback texture. @@ -654,25 +636,26 @@ update_texture_state( struct gl_context *ctx ) ctx-Texture._EnabledUnits |= (1 unit); - if (enabledFragTargets) + if (enabledTargetsByStage[MESA_SHADER_FRAGMENT]) enabledFragUnits |= (1 unit); - if (!fprog) + if (!prog[MESA_SHADER_FRAGMENT]) update_tex_combine(ctx, texUnit); } /* Determine which texture coordinate sets are actually needed */ - if (fprog) { + if (prog[MESA_SHADER_FRAGMENT]) { const GLuint coordMask = (1 MAX_TEXTURE_COORD_UNITS) - 1; ctx-Texture._EnabledCoordUnits - = (fprog-InputsRead VARYING_SLOT_TEX0) coordMask; + = (prog[MESA_SHADER_FRAGMENT]-InputsRead VARYING_SLOT_TEX0) + coordMask; } else { ctx-Texture._EnabledCoordUnits = enabledFragUnits; } - if (!fprog || !vprog) + if (!prog[MESA_SHADER_FRAGMENT] || !prog[MESA_SHADER_VERTEX]) update_texgen(ctx); } -- 1.8.5.2 ___ mesa-dev mailing list
[Mesa-dev] [PATCH 16/30] mesa/cs: Add a MESA_SHADER_COMPUTE stage and update switch statements.
This patch adds MESA_SHADER_COMPUTE to the gl_shader_stage enum. Also, where it is trivial to do so, it adds a compute shader case to switch statements that switch based on the type of shader. This avoids unhandled switch case compiler warnings. --- src/glsl/ast_to_hir.cpp | 9 + src/glsl/builtin_variables.cpp| 17 + src/glsl/standalone_scaffolding.h | 2 ++ src/mesa/main/context.c | 8 src/mesa/main/mtypes.h| 3 ++- src/mesa/main/shaderapi.c | 5 + src/mesa/main/shaderobj.h | 2 ++ src/mesa/program/prog_print.c | 3 +++ src/mesa/program/program.h| 4 9 files changed, 52 insertions(+), 1 deletion(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index ef8e699..a26745d 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -2093,6 +2093,12 @@ validate_explicit_location(const struct ast_type_qualifier *qual, fail = true; break; + + case MESA_SHADER_COMPUTE: + _mesa_glsl_error(loc, state, + compute shader variables cannot be given + explicit locations); + return; }; if (fail) { @@ -2275,6 +2281,9 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, if (var-data.mode == ir_var_shader_in) var-data.invariant = true; break; + case MESA_SHADER_COMPUTE: + /* Invariance isn't meaningful in compute shaders. */ + break; } } diff --git a/src/glsl/builtin_variables.cpp b/src/glsl/builtin_variables.cpp index f630923..17ae087 100644 --- a/src/glsl/builtin_variables.cpp +++ b/src/glsl/builtin_variables.cpp @@ -356,6 +356,7 @@ public: void generate_vs_special_vars(); void generate_gs_special_vars(); void generate_fs_special_vars(); + void generate_cs_special_vars(); void generate_varyings(); private: @@ -866,6 +867,16 @@ builtin_variable_generator::generate_fs_special_vars() /** + * Generate variables which only exist in compute shaders. + */ +void +builtin_variable_generator::generate_cs_special_vars() +{ + /* TODO: finish this. */ +} + + +/** * Add a single varying variable. The variable's type and direction (input * or output) are adjusted as appropriate for the type of shader being * compiled. For geometry shaders using {ARB,EXT}_geometry_shader4, @@ -886,6 +897,9 @@ builtin_variable_generator::add_varying(int slot, const glsl_type *type, case MESA_SHADER_FRAGMENT: add_input(slot, type, name); break; + case MESA_SHADER_COMPUTE: + /* Compute shaders don't have varyings. */ + break; } } @@ -973,5 +987,8 @@ _mesa_glsl_initialize_variables(exec_list *instructions, case MESA_SHADER_FRAGMENT: gen.generate_fs_special_vars(); break; + case MESA_SHADER_COMPUTE: + gen.generate_cs_special_vars(); + break; } } diff --git a/src/glsl/standalone_scaffolding.h b/src/glsl/standalone_scaffolding.h index 327fef2..df783af 100644 --- a/src/glsl/standalone_scaffolding.h +++ b/src/glsl/standalone_scaffolding.h @@ -58,6 +58,8 @@ _mesa_shader_enum_to_shader_stage(GLenum v) return MESA_SHADER_FRAGMENT; case GL_GEOMETRY_SHADER: return MESA_SHADER_GEOMETRY; + case GL_COMPUTE_SHADER: + return MESA_SHADER_COMPUTE; default: assert(!bad value in _mesa_shader_enum_to_shader_stage()); return MESA_SHADER_VERTEX; diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 5855f15..b0cf5da 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -498,6 +498,14 @@ init_program_limits(struct gl_context *ctx, gl_shader_stage stage, prog-MaxInputComponents = 16 * 4; /* old limit not to break tnl and swrast */ prog-MaxOutputComponents = 16 * 4; /* old limit not to break tnl and swrast */ break; + case MESA_SHADER_COMPUTE: + prog-MaxParameters = 0; /* not meaningful for compute shaders */ + prog-MaxAttribs = 0; /* not meaningful for compute shaders */ + prog-MaxAddressRegs = 0; /* not meaningful for compute shaders */ + prog-MaxUniformComponents = 4 * MAX_UNIFORMS; + prog-MaxInputComponents = 0; /* not meaningful for compute shaders */ + prog-MaxOutputComponents = 0; /* not meaningful for compute shaders */ + break; default: assert(0 Bad shader stage in init_program_limits()); } diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 7ba7b10..8b88d75 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -404,9 +404,10 @@ typedef enum MESA_SHADER_VERTEX = 0, MESA_SHADER_GEOMETRY = 1, MESA_SHADER_FRAGMENT = 2, + MESA_SHADER_COMPUTE = 3, } gl_shader_stage; -#define MESA_SHADER_STAGES (MESA_SHADER_FRAGMENT + 1) +#define MESA_SHADER_STAGES (MESA_SHADER_COMPUTE + 1) /** diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index 61ac0e3..519b200
[Mesa-dev] [PATCH 19/30] mesa/cs: Handle compute shaders in _mesa_use_program().
--- src/mesa/main/shaderapi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index 519b200..5188e9c 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -993,6 +993,7 @@ _mesa_use_program(struct gl_context *ctx, struct gl_shader_program *shProg) { use_shader_program(ctx, GL_VERTEX_SHADER, shProg); use_shader_program(ctx, GL_GEOMETRY_SHADER_ARB, shProg); + use_shader_program(ctx, GL_COMPUTE_SHADER, shProg); use_shader_program(ctx, GL_FRAGMENT_SHADER, shProg); _mesa_active_program(ctx, shProg, glUseProgram); -- 1.8.5.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 17/30] glsl/cs: Populate default values for ctx-Const.Program[MESA_SHADER_COMPUTE].
--- src/glsl/main.cpp | 4 src/glsl/standalone_scaffolding.cpp | 4 2 files changed, 8 insertions(+) diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp index 03b7c78..afc15cb 100644 --- a/src/glsl/main.cpp +++ b/src/glsl/main.cpp @@ -50,6 +50,10 @@ initialize_context(struct gl_context *ctx, gl_api api) */ ctx-Const.GLSLVersion = glsl_version; ctx-Extensions.ARB_ES3_compatibility = true; + ctx-Const.Program[MESA_SHADER_COMPUTE].MaxTextureImageUnits = 16; + ctx-Const.Program[MESA_SHADER_COMPUTE].MaxUniformComponents = 1024; + ctx-Const.Program[MESA_SHADER_COMPUTE].MaxInputComponents = 0; /* not used */ + ctx-Const.Program[MESA_SHADER_COMPUTE].MaxOutputComponents = 0; /* not used */ switch (ctx-Const.GLSLVersion) { case 100: diff --git a/src/glsl/standalone_scaffolding.cpp b/src/glsl/standalone_scaffolding.cpp index fe66067..ab92da8 100644 --- a/src/glsl/standalone_scaffolding.cpp +++ b/src/glsl/standalone_scaffolding.cpp @@ -140,6 +140,10 @@ void initialize_context_to_defaults(struct gl_context *ctx, gl_api api) ctx-Const.Program[MESA_SHADER_FRAGMENT].MaxInputComponents = 32; ctx-Const.MaxDrawBuffers = 1; + ctx-Const.Program[MESA_SHADER_COMPUTE].MaxTextureImageUnits = 16; + ctx-Const.Program[MESA_SHADER_COMPUTE].MaxUniformComponents = 1024; + ctx-Const.Program[MESA_SHADER_COMPUTE].MaxInputComponents = 0; /* not used */ + ctx-Const.Program[MESA_SHADER_COMPUTE].MaxOutputComponents = 0; /* not used */ /* Set up default shader compiler options. */ struct gl_shader_compiler_options options; -- 1.8.5.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 29/30] i965/cs: Create the brw_compute_program struct, and the code to initialize it.
--- src/mesa/drivers/dri/i965/brw_context.h | 8 src/mesa/drivers/dri/i965/brw_program.c | 11 +++ 2 files changed, 19 insertions(+) diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index df32ccb..abc1783 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -316,6 +316,14 @@ struct brw_fragment_program { GLuint id; /** serial no. to identify frag progs, never re-used */ }; + +/** Subclass of Mesa compute program */ +struct brw_compute_program { + struct gl_compute_program program; + unsigned id; /** serial no. to identify frag progs, never re-used */ +}; + + struct brw_shader { struct gl_shader base; diff --git a/src/mesa/drivers/dri/i965/brw_program.c b/src/mesa/drivers/dri/i965/brw_program.c index 90844e5..2d92acb 100644 --- a/src/mesa/drivers/dri/i965/brw_program.c +++ b/src/mesa/drivers/dri/i965/brw_program.c @@ -113,6 +113,17 @@ static struct gl_program *brwNewProgram( struct gl_context *ctx, } } + case GL_COMPUTE_PROGRAM_NV: { + struct brw_compute_program *prog = CALLOC_STRUCT(brw_compute_program); + if (prog) { + prog-id = get_new_program_id(brw-intelScreen); + + return _mesa_init_compute_program(ctx, prog-program, target, id); + } else { + return NULL; + } + } + default: assert(!Unsupported target in brwNewProgram()); return NULL; -- 1.8.5.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 09/30] meta: Replace save_state::{Vertex, Geometry, Fragment}Shader with an array.
Since ctx-Shader.Current{Vertex,Geometry,Fragment}Program is an array, this allows some meta code to be rolled up into loops. --- src/mesa/drivers/common/meta.c | 30 ++ 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c index 5643e3c..2eeb09b 100644 --- a/src/mesa/drivers/common/meta.c +++ b/src/mesa/drivers/common/meta.c @@ -138,9 +138,7 @@ struct save_state GLboolean FragmentProgramEnabled; struct gl_fragment_program *FragmentProgram; GLboolean ATIFragmentShaderEnabled; - struct gl_shader_program *VertexShader; - struct gl_shader_program *GeometryShader; - struct gl_shader_program *FragmentShader; + struct gl_shader_program *Shader[MESA_SHADER_STAGES]; struct gl_shader_program *ActiveShader; /** MESA_META_STENCIL_TEST */ @@ -617,12 +615,10 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state) _mesa_set_enable(ctx, GL_FRAGMENT_SHADER_ATI, GL_FALSE); } - _mesa_reference_shader_program(ctx, save-VertexShader, - ctx-Shader.CurrentProgram[MESA_SHADER_VERTEX]); - _mesa_reference_shader_program(ctx, save-GeometryShader, - ctx-Shader.CurrentProgram[MESA_SHADER_GEOMETRY]); - _mesa_reference_shader_program(ctx, save-FragmentShader, - ctx-Shader.CurrentProgram[MESA_SHADER_FRAGMENT]); + for (int i = 0; i MESA_SHADER_STAGES; i++) { + _mesa_reference_shader_program(ctx, save-Shader[i], + ctx-Shader.CurrentProgram[i]); + } _mesa_reference_shader_program(ctx, save-ActiveShader, ctx-Shader.ActiveProgram); @@ -829,6 +825,7 @@ _mesa_meta_end(struct gl_context *ctx) { struct save_state *save = ctx-Meta-Save[ctx-Meta-SaveStackDepth - 1]; const GLbitfield state = save-SavedState; + int i; /* After starting a new occlusion query, initialize the results to the * values saved previously. The driver will then continue to increment @@ -960,23 +957,24 @@ _mesa_meta_end(struct gl_context *ctx) save-ATIFragmentShaderEnabled); } - if (ctx-Extensions.ARB_vertex_shader) -_mesa_use_shader_program(ctx, GL_VERTEX_SHADER, save-VertexShader); + if (ctx-Extensions.ARB_vertex_shader) { +_mesa_use_shader_program(ctx, GL_VERTEX_SHADER, + save-Shader[MESA_SHADER_VERTEX]); + } if (_mesa_has_geometry_shaders(ctx)) _mesa_use_shader_program(ctx, GL_GEOMETRY_SHADER_ARB, - save-GeometryShader); + save-Shader[MESA_SHADER_GEOMETRY]); if (ctx-Extensions.ARB_fragment_shader) _mesa_use_shader_program(ctx, GL_FRAGMENT_SHADER, - save-FragmentShader); + save-Shader[MESA_SHADER_FRAGMENT]); _mesa_reference_shader_program(ctx, ctx-Shader.ActiveProgram, save-ActiveShader); - _mesa_reference_shader_program(ctx, save-VertexShader, NULL); - _mesa_reference_shader_program(ctx, save-GeometryShader, NULL); - _mesa_reference_shader_program(ctx, save-FragmentShader, NULL); + for (i = 0; i MESA_SHADER_STAGES; i++) + _mesa_reference_shader_program(ctx, save-Shader[i], NULL); _mesa_reference_shader_program(ctx, save-ActiveShader, NULL); } -- 1.8.5.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 14/30] mesa/cs: Add dispatch API stubs for ARB_compute_shader.
--- src/mapi/glapi/gen/ARB_compute_shader.xml | 40 +++ src/mapi/glapi/gen/Makefile.am| 1 + src/mapi/glapi/gen/gl_API.xml | 4 ++- src/mapi/glapi/gen/gl_genexec.py | 1 + src/mesa/Makefile.sources | 1 + src/mesa/SConscript | 1 + src/mesa/main/compute.c | 54 +++ src/mesa/main/compute.h | 38 ++ src/mesa/main/tests/dispatch_sanity.cpp | 4 +-- 9 files changed, 141 insertions(+), 3 deletions(-) create mode 100644 src/mapi/glapi/gen/ARB_compute_shader.xml create mode 100644 src/mesa/main/compute.c create mode 100644 src/mesa/main/compute.h diff --git a/src/mapi/glapi/gen/ARB_compute_shader.xml b/src/mapi/glapi/gen/ARB_compute_shader.xml new file mode 100644 index 000..1db373e --- /dev/null +++ b/src/mapi/glapi/gen/ARB_compute_shader.xml @@ -0,0 +1,40 @@ +?xml version=1.0? +!DOCTYPE OpenGLAPI SYSTEM gl_API.dtd + +!-- Note: no GLX protocol info yet. -- + + +OpenGLAPI + +category name=GL_ARB_compute_shader number=122 + enum name=COMPUTE_SHADER value=0x91B9/ + enum name=MAX_COMPUTE_UNIFORM_BLOCKS value=0x91BB/ + enum name=MAX_COMPUTE_TEXTURE_IMAGE_UNITS value=0x91BC/ + enum name=MAX_COMPUTE_IMAGE_UNIFORMS value=0x91BD/ + enum name=MAX_COMPUTE_SHARED_MEMORY_SIZE value=0x8262/ + enum name=MAX_COMPUTE_UNIFORM_COMPONENTS value=0x8263/ + enum name=MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS value=0x8264/ + enum name=MAX_COMPUTE_ATOMIC_COUNTERS value=0x8265/ + enum name=MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS value=0x8266/ + enum name=MAX_COMPUTE_WORK_GROUP_INVOCATIONS value=0x90EB/ + enum name=MAX_COMPUTE_WORK_GROUP_COUNTvalue=0x91BE/ + enum name=MAX_COMPUTE_WORK_GROUP_SIZE value=0x91BF/ + enum name=COMPUTE_WORK_GROUP_SIZE value=0x8267/ + enum name=UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER value=0x90EC/ + enum name=ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER value=0x90ED/ + enum name=DISPATCH_INDIRECT_BUFFERvalue=0x90EE/ + enum name=DISPATCH_INDIRECT_BUFFER_BINDINGvalue=0x90EF/ + enum name=COMPUTE_SHADER_BIT value=0x0020/ + + function name=DispatchCompute offset=assign +param name=num_groups_x type=GLuint/ +param name=num_groups_y type=GLuint/ +param name=num_groups_z type=GLuint/ + /function + + function name=DispatchComputeIndirect offset=assign +param name=indirect type=GLintptr/ + /function +/category + +/OpenGLAPI diff --git a/src/mapi/glapi/gen/Makefile.am b/src/mapi/glapi/gen/Makefile.am index 65bd913..a9cf2a31 100644 --- a/src/mapi/glapi/gen/Makefile.am +++ b/src/mapi/glapi/gen/Makefile.am @@ -91,6 +91,7 @@ API_XML = \ ARB_base_instance.xml \ ARB_blend_func_extended.xml \ ARB_color_buffer_float.xml \ + ARB_compute_shader.xml \ ARB_copy_buffer.xml \ ARB_debug_output.xml \ ARB_depth_buffer_float.xml \ diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml index 697b2ec..d6cd1f5 100644 --- a/src/mapi/glapi/gen/gl_API.xml +++ b/src/mapi/glapi/gen/gl_API.xml @@ -8464,7 +8464,9 @@ xi:include href=ARB_clear_buffer_object.xml xmlns:xi=http://www.w3.org/2001/XInclude/ -!-- ARB extensions #122...#123 -- +xi:include href=ARB_compute_shader.xml xmlns:xi=http://www.w3.org/2001/XInclude/ + +!-- ARB extension #123 -- xi:include href=ARB_texture_view.xml xmlns:xi=http://www.w3.org/2001/XInclude/ diff --git a/src/mapi/glapi/gen/gl_genexec.py b/src/mapi/glapi/gen/gl_genexec.py index b557b3b..e376da3 100644 --- a/src/mapi/glapi/gen/gl_genexec.py +++ b/src/mapi/glapi/gen/gl_genexec.py @@ -57,6 +57,7 @@ header = /** #include main/clear.h #include main/clip.h #include main/colortab.h +#include main/compute.h #include main/condrender.h #include main/context.h #include main/convolve.h diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources index 39525bc..2fdc2b6 100644 --- a/src/mesa/Makefile.sources +++ b/src/mesa/Makefile.sources @@ -23,6 +23,7 @@ MAIN_FILES = \ $(SRCDIR)main/clear.c \ $(SRCDIR)main/clip.c \ $(SRCDIR)main/colortab.c \ + $(SRCDIR)main/compute.c \ $(SRCDIR)main/condrender.c \ $(SRCDIR)main/context.c \ $(SRCDIR)main/convolve.c \ diff --git a/src/mesa/SConscript b/src/mesa/SConscript index bb9b304..24264c8 100644 --- a/src/mesa/SConscript +++ b/src/mesa/SConscript @@ -51,6 +51,7 @@ main_sources = [ 'main/clear.c', 'main/clip.c', 'main/colortab.c', +'main/compute.c', 'main/condrender.c', 'main/context.c', 'main/convolve.c', diff --git a/src/mesa/main/compute.c
[Mesa-dev] [PATCH 28/30] glsl/cs: Prohibit mixing of compute and non-compute shaders.
Fixes piglit test: spec/ARB_compute_shader/linker/mix_compute_and_non_compute --- src/glsl/linker.cpp | 7 +++ 1 file changed, 7 insertions(+) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index 11e0651..f1344ea 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -2107,6 +2107,13 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog) goto done; } + /* Compute shaders have additional restrictions. */ + if (num_shaders[MESA_SHADER_COMPUTE] 0 + num_shaders[MESA_SHADER_COMPUTE] != prog-NumShaders) { + linker_error(prog, Compute shaders may not be linked with any other + type of shader\n); + } + for (unsigned int i = 0; i MESA_SHADER_STAGES; i++) { if (prog-_LinkedShaders[i] != NULL) ctx-Driver.DeleteShader(ctx, prog-_LinkedShaders[i]); -- 1.8.5.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 00/30] mesa: Start implementing compute shaders.
This is the first of several planned patch series to implement the extension ARB_compute_shader in Mesa. This series allows the Mesa front-end to parse and compile a do-nothing compute shader--that is, one which contains nothing but a compute shader input layout declaration and an empty main() function. Since compute shader support is not yet complete, I haven't enabled it. To try it out, set the environment variable INTEL_COMPUTE_SHADER=1. With that environment variable set, the series passes all of the ARB_compute_shader tests I recently sent to the Piglit mailing list, except for the minmax test. Patches 01-12 do preparatory refactoring in order to make adding compute shaders (and other future shader stages) easier. Patch 13 adds the extension enable flags for compute shaders, both in the context and in the GLSL compiler. Patch 14 adds the ARB_compute_shader functions and enums to Mesa's dispatch code generation logic. The functions don't do anything yet. Patch 15 changes the linker so that once the compute shader stage has been added, it won't mistakenly consider it to be part of the rest of the graphics pipeline. Patches 16-20 add MESA_SHADER_COMPUTE to the gl_shader_stage enum, and update the rest of the code base to accommodate its presence in the enum. Patches 21-23 implement some compute shader constants. Patches 24-26 implement logic to handle compute shader work group sizes (also known as local sizes). Patches 27-28 implement two other basic rules of compute shaders (they don't have user-defined ins/outs, and they can't be mixed with other shader types). Finally, patches 29-30 implement the necessary back-end code for the i965 driver to allow compute shaders to be turned on with an environment variable. Once these patches land, I plan to start working on the i965 back end. [PATCH 01/30] mesa: Replace _mesa_program_index_to_target with _mesa_shader_stage_to_program. [PATCH 02/30] mesa: Make validate_shader_target() non-static. [PATCH 03/30] main: Allow ctx == NULL in _mesa_validate_shader_target(). [PATCH 04/30] mesa: use _mesa_validate_shader_target() more frequently. [PATCH 05/30] glsl/linker: Refactor in preparation for adding more shader stages. [PATCH 06/30] mesa: Replace ctx-Shader.Current{Vertex,Fragment,Geometry}Program with an array. [PATCH 07/30] mesa: Fold long lines introduced by the previous patch. [PATCH 08/30] i965: Fix comments to refer to the new ctx-Shader.CurrentProgram array. [PATCH 09/30] meta: Replace save_state::{Vertex,Geometry,Fragment}Shader with an array. [PATCH 10/30] mesa: Remove ad-hoc arrays of gl_shader_program. [PATCH 11/30] mesa: Change redundant code into loops in shaderapi.c. [PATCH 12/30] mesa: Change redundant code into loops in texstate.c. [PATCH 13/30] mesa/cs: Add extension enable flags for ARB_compute_shader. [PATCH 14/30] mesa/cs: Add dispatch API stubs for ARB_compute_shader. [PATCH 15/30] glsl/cs: Change some linker loops to use MESA_SHADER_FRAGMENT as a bound. [PATCH 16/30] mesa/cs: Add a MESA_SHADER_COMPUTE stage and update statements. [PATCH 17/30] glsl/cs: Populate default values for ctx-Const.Program[MESA_SHADER_COMPUTE]. [PATCH 18/30] glsl/cs: update main.cpp to use the .comp extension for compute shaders. [PATCH 19/30] mesa/cs: Handle compute shaders in _mesa_use_program(). [PATCH 20/30] mesa/cs: Create the gl_compute_program struct, and the code to initialize it. [PATCH 21/30] mesa/cs: Implement MAX_COMPUTE_WORK_GROUP_SIZE constant. [PATCH 22/30] mesa/cs: Implement MAX_COMPUTE_WORK_GROUP_INVOCATIONS constant. [PATCH 23/30] mesa/cs: Implement MAX_COMPUTE_WORK_GROUP_COUNT constant. [PATCH 24/30] glsl/cs: Handle compute shader local_size_{x,y,z} declaration. [PATCH 25/30] mesa/cs: Handle compute shader local size during linking. [PATCH 26/30] main/cs: Implement query for COMPUTE_WORK_GROUP_SIZE. [PATCH 27/30] glsl/cs: Prohibit user-defined ins/outs in compute shaders. [PATCH 28/30] glsl/cs: Prohibit mixing of compute and non-compute shaders. [PATCH 29/30] i965/cs: Create the brw_compute_program struct, and the code to initialize it. [PATCH 30/30] i965/cs: Allow ARB_compute_shader to be enabled via env var. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 21/30] mesa/cs: Implement MAX_COMPUTE_WORK_GROUP_SIZE constant.
--- src/glsl/builtin_variables.cpp | 27 +++ src/glsl/glsl_parser_extras.cpp | 4 src/glsl/glsl_parser_extras.h | 3 +++ src/glsl/main.cpp | 3 +++ src/glsl/standalone_scaffolding.cpp | 3 +++ src/mesa/main/context.c | 5 + src/mesa/main/get.c | 8 src/mesa/main/mtypes.h | 3 +++ 8 files changed, 56 insertions(+) diff --git a/src/glsl/builtin_variables.cpp b/src/glsl/builtin_variables.cpp index 17ae087..171bf08 100644 --- a/src/glsl/builtin_variables.cpp +++ b/src/glsl/builtin_variables.cpp @@ -390,6 +390,7 @@ private: enum ir_variable_mode mode, int slot); ir_variable *add_uniform(const glsl_type *type, const char *name); ir_variable *add_const(const char *name, int value); + ir_variable *add_const_ivec3(const char *name, int x, int y, int z); void add_varying(int slot, const glsl_type *type, const char *name, const char *name_as_gs_input); @@ -530,6 +531,25 @@ builtin_variable_generator::add_const(const char *name, int value) } +ir_variable * +builtin_variable_generator::add_const_ivec3(const char *name, int x, int y, +int z) +{ + ir_variable *const var = add_variable(name, glsl_type::ivec3_type, + ir_var_auto, -1); + ir_constant_data data; + memset(data, 0, sizeof(data)); + data.i[0] = x; + data.i[1] = y; + data.i[2] = z; + var-constant_value = new(var) ir_constant(glsl_type::ivec3_type, data); + var-constant_initializer = + new(var) ir_constant(glsl_type::ivec3_type, data); + var-data.has_initializer = true; + return var; +} + + void builtin_variable_generator::generate_constants() { @@ -660,6 +680,13 @@ builtin_variable_generator::generate_constants() add_const(gl_MaxTessControlAtomicCounters, 0); add_const(gl_MaxTessEvaluationAtomicCounters, 0); } + + if (state-is_version(430, 0) || state-ARB_compute_shader_enable) { + add_const_ivec3(gl_MaxComputeWorkGroupSize, + state-Const.MaxComputeWorkGroupSize[0], + state-Const.MaxComputeWorkGroupSize[1], + state-Const.MaxComputeWorkGroupSize[2]); + } } diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp index 33a43c5..8524fc6 100644 --- a/src/glsl/glsl_parser_extras.cpp +++ b/src/glsl/glsl_parser_extras.cpp @@ -123,6 +123,10 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx, this-Const.MaxCombinedAtomicCounters = ctx-Const.MaxCombinedAtomicCounters; this-Const.MaxAtomicBufferBindings = ctx-Const.MaxAtomicBufferBindings; + /* Compute shader constants */ + for (unsigned i = 0; i Elements(this-Const.MaxComputeWorkGroupSize); i++) + this-Const.MaxComputeWorkGroupSize[i] = ctx-Const.MaxComputeWorkGroupSize[i]; + this-current_function = NULL; this-toplevel_ir = NULL; this-found_return = false; diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h index 468707c..be34fd9 100644 --- a/src/glsl/glsl_parser_extras.h +++ b/src/glsl/glsl_parser_extras.h @@ -250,6 +250,9 @@ struct _mesa_glsl_parse_state { unsigned MaxFragmentAtomicCounters; unsigned MaxCombinedAtomicCounters; unsigned MaxAtomicBufferBindings; + + /* ARB_compute_shader */ + unsigned MaxComputeWorkGroupSize[3]; } Const; /** diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp index 864c929..bb2054f 100644 --- a/src/glsl/main.cpp +++ b/src/glsl/main.cpp @@ -50,6 +50,9 @@ initialize_context(struct gl_context *ctx, gl_api api) */ ctx-Const.GLSLVersion = glsl_version; ctx-Extensions.ARB_ES3_compatibility = true; + ctx-Const.MaxComputeWorkGroupSize[0] = 1024; + ctx-Const.MaxComputeWorkGroupSize[1] = 1024; + ctx-Const.MaxComputeWorkGroupSize[2] = 64; ctx-Const.Program[MESA_SHADER_COMPUTE].MaxTextureImageUnits = 16; ctx-Const.Program[MESA_SHADER_COMPUTE].MaxUniformComponents = 1024; ctx-Const.Program[MESA_SHADER_COMPUTE].MaxInputComponents = 0; /* not used */ diff --git a/src/glsl/standalone_scaffolding.cpp b/src/glsl/standalone_scaffolding.cpp index ab92da8..e8eb529 100644 --- a/src/glsl/standalone_scaffolding.cpp +++ b/src/glsl/standalone_scaffolding.cpp @@ -140,6 +140,9 @@ void initialize_context_to_defaults(struct gl_context *ctx, gl_api api) ctx-Const.Program[MESA_SHADER_FRAGMENT].MaxInputComponents = 32; ctx-Const.MaxDrawBuffers = 1; + ctx-Const.MaxComputeWorkGroupSize[0] = 1024; + ctx-Const.MaxComputeWorkGroupSize[1] = 1024; + ctx-Const.MaxComputeWorkGroupSize[2] = 64; ctx-Const.Program[MESA_SHADER_COMPUTE].MaxTextureImageUnits = 16; ctx-Const.Program[MESA_SHADER_COMPUTE].MaxUniformComponents = 1024; ctx-Const.Program[MESA_SHADER_COMPUTE].MaxInputComponents = 0; /* not used */ diff --git
[Mesa-dev] [PATCH 25/30] mesa/cs: Handle compute shader local size during linking.
--- src/glsl/linker.cpp | 64 +++ src/mesa/main/mtypes.h| 17 + src/mesa/main/shaderapi.c | 7 ++ 3 files changed, 88 insertions(+) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index 7461b17..11e0651 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -1284,6 +1284,69 @@ link_gs_inout_layout_qualifiers(struct gl_shader_program *prog, prog-Geom.VerticesOut = linked_shader-Geom.VerticesOut; } + +/** + * Perform cross-validation of compute shader local_size_{x,y,z} layout + * qualifiers for the attached compute shaders, and propagate them to the + * linked CS and linked shader program. + */ +static void +link_cs_input_layout_qualifiers(struct gl_shader_program *prog, +struct gl_shader *linked_shader, +struct gl_shader **shader_list, +unsigned num_shaders) +{ + for (int i = 0; i 3; i++) + linked_shader-Comp.LocalSize[i] = 0; + + /* This function is called for all shader stages, but it only has an effect +* for compute shaders. +*/ + if (linked_shader-Stage != MESA_SHADER_COMPUTE) + return; + + /* From the ARB_compute_shader spec, in the section describing local size +* declarations: +* +* If multiple compute shaders attached to a single program object +* declare local work-group size, the declarations must be identical; +* otherwise a link-time error results. Furthermore, if a program +* object contains any compute shaders, at least one must contain an +* input layout qualifier specifying the local work sizes of the +* program, or a link-time error will occur. +*/ + for (unsigned sh = 0; sh num_shaders; sh++) { + struct gl_shader *shader = shader_list[sh]; + + if (shader-Comp.LocalSize[0] != 0) { + if (linked_shader-Comp.LocalSize[0] != 0) { +for (int i = 0; i 3; i++) { + if (linked_shader-Comp.LocalSize[i] != + shader-Comp.LocalSize[i]) { + linker_error(prog, compute shader defined with conflicting + local sizes\n); + return; + } +} + } + for (int i = 0; i 3; i++) +linked_shader-Comp.LocalSize[i] = shader-Comp.LocalSize[i]; + } + } + + /* Just do the intrastage - interstage propagation right now, +* since we already know we're in the right type of shader program +* for doing it. +*/ + if (linked_shader-Comp.LocalSize[0] == 0) { + linker_error(prog, compute shader didn't declare local size\n); + return; + } + for (int i = 0; i 3; i++) + prog-Comp.LocalSize[i] = linked_shader-Comp.LocalSize[i]; +} + + /** * Combine a group of shaders for a single stage to generate a linked shader * @@ -1389,6 +1452,7 @@ link_intrastage_shaders(void *mem_ctx, ralloc_steal(linked, linked-UniformBlocks); link_gs_inout_layout_qualifiers(prog, linked, shader_list, num_shaders); + link_cs_input_layout_qualifiers(prog, linked, shader_list, num_shaders); populate_symbol_table(linked); diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index e0c88a7..56e120b 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2171,6 +2171,11 @@ struct gl_fragment_program struct gl_compute_program { struct gl_program Base; /** base class */ + + /** +* Size specified using local_size_{x,y,z}. +*/ + unsigned LocalSize[3]; }; @@ -2606,6 +2611,18 @@ struct gl_shader_program 0 if not present. */ } Vert; + /** +* Compute shader state - copied into gl_compute_program by +* _mesa_copy_linked_program_data(). +*/ + struct { + /** + * If this shader contains a compute stage, size specified using + * local_size_{x,y,z}. Otherwise undefined. + */ + unsigned LocalSize[3]; + } Comp; + /* post-link info: */ unsigned NumUserUniformStorage; struct gl_uniform_storage *UniformStorage; diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index 5188e9c..053f27b 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -1846,6 +1846,13 @@ _mesa_copy_linked_program_data(gl_shader_stage type, dst_gp-UsesEndPrimitive = src-Geom.UsesEndPrimitive; } break; + case MESA_SHADER_COMPUTE: { + struct gl_compute_program *dst_cp = (struct gl_compute_program *) dst; + int i; + for (i = 0; i 3; i++) + dst_cp-LocalSize[i] = src-Comp.LocalSize[i]; + } + break; default: break; } -- 1.8.5.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 23/30] mesa/cs: Implement MAX_COMPUTE_WORK_GROUP_COUNT constant.
--- src/glsl/builtin_variables.cpp | 4 src/glsl/glsl_parser_extras.cpp | 2 ++ src/glsl/glsl_parser_extras.h | 1 + src/glsl/main.cpp | 3 +++ src/glsl/standalone_scaffolding.cpp | 3 +++ src/mesa/main/context.c | 3 +++ src/mesa/main/get.c | 8 src/mesa/main/mtypes.h | 1 + 8 files changed, 25 insertions(+) diff --git a/src/glsl/builtin_variables.cpp b/src/glsl/builtin_variables.cpp index 171bf08..f94f5da 100644 --- a/src/glsl/builtin_variables.cpp +++ b/src/glsl/builtin_variables.cpp @@ -682,6 +682,10 @@ builtin_variable_generator::generate_constants() } if (state-is_version(430, 0) || state-ARB_compute_shader_enable) { + add_const_ivec3(gl_MaxComputeWorkGroupCount, + state-Const.MaxComputeWorkGroupCount[0], + state-Const.MaxComputeWorkGroupCount[1], + state-Const.MaxComputeWorkGroupCount[2]); add_const_ivec3(gl_MaxComputeWorkGroupSize, state-Const.MaxComputeWorkGroupSize[0], state-Const.MaxComputeWorkGroupSize[1], diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp index 8524fc6..65c504f 100644 --- a/src/glsl/glsl_parser_extras.cpp +++ b/src/glsl/glsl_parser_extras.cpp @@ -124,6 +124,8 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx, this-Const.MaxAtomicBufferBindings = ctx-Const.MaxAtomicBufferBindings; /* Compute shader constants */ + for (unsigned i = 0; i Elements(this-Const.MaxComputeWorkGroupCount); i++) + this-Const.MaxComputeWorkGroupCount[i] = ctx-Const.MaxComputeWorkGroupCount[i]; for (unsigned i = 0; i Elements(this-Const.MaxComputeWorkGroupSize); i++) this-Const.MaxComputeWorkGroupSize[i] = ctx-Const.MaxComputeWorkGroupSize[i]; diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h index be34fd9..68a3d54 100644 --- a/src/glsl/glsl_parser_extras.h +++ b/src/glsl/glsl_parser_extras.h @@ -252,6 +252,7 @@ struct _mesa_glsl_parse_state { unsigned MaxAtomicBufferBindings; /* ARB_compute_shader */ + unsigned MaxComputeWorkGroupCount[3]; unsigned MaxComputeWorkGroupSize[3]; } Const; diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp index 94bc1cc..5ea57d5 100644 --- a/src/glsl/main.cpp +++ b/src/glsl/main.cpp @@ -50,6 +50,9 @@ initialize_context(struct gl_context *ctx, gl_api api) */ ctx-Const.GLSLVersion = glsl_version; ctx-Extensions.ARB_ES3_compatibility = true; + ctx-Const.MaxComputeWorkGroupCount[0] = 65535; + ctx-Const.MaxComputeWorkGroupCount[1] = 65535; + ctx-Const.MaxComputeWorkGroupCount[2] = 65535; ctx-Const.MaxComputeWorkGroupSize[0] = 1024; ctx-Const.MaxComputeWorkGroupSize[1] = 1024; ctx-Const.MaxComputeWorkGroupSize[2] = 64; diff --git a/src/glsl/standalone_scaffolding.cpp b/src/glsl/standalone_scaffolding.cpp index 0c83ea3..cce2dce 100644 --- a/src/glsl/standalone_scaffolding.cpp +++ b/src/glsl/standalone_scaffolding.cpp @@ -140,6 +140,9 @@ void initialize_context_to_defaults(struct gl_context *ctx, gl_api api) ctx-Const.Program[MESA_SHADER_FRAGMENT].MaxInputComponents = 32; ctx-Const.MaxDrawBuffers = 1; + ctx-Const.MaxComputeWorkGroupCount[0] = 65535; + ctx-Const.MaxComputeWorkGroupCount[1] = 65535; + ctx-Const.MaxComputeWorkGroupCount[2] = 65535; ctx-Const.MaxComputeWorkGroupSize[0] = 1024; ctx-Const.MaxComputeWorkGroupSize[1] = 1024; ctx-Const.MaxComputeWorkGroupSize[2] = 64; diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 942f247..6d7e467 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -692,6 +692,9 @@ _mesa_init_constants(struct gl_context *ctx) ctx-Const.MaxVertexAttribBindings = MAX_VERTEX_GENERIC_ATTRIBS; /* GL_ARB_compute_shader */ + ctx-Const.MaxComputeWorkGroupCount[0] = 65535; + ctx-Const.MaxComputeWorkGroupCount[1] = 65535; + ctx-Const.MaxComputeWorkGroupCount[2] = 65535; ctx-Const.MaxComputeWorkGroupSize[0] = 1024; ctx-Const.MaxComputeWorkGroupSize[1] = 1024; ctx-Const.MaxComputeWorkGroupSize[2] = 64; diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index bcbb5d5..e977521 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -1791,6 +1791,14 @@ find_value_indexed(const char *func, GLenum pname, GLuint index, union value *v) v-value_int = ctx-Array.ArrayObj-VertexBinding[VERT_ATTRIB_GENERIC(index)].Stride; return TYPE_INT; + case GL_MAX_COMPUTE_WORK_GROUP_COUNT: + if (!_mesa_is_desktop_gl(ctx) || !ctx-Extensions.ARB_compute_shader) + goto invalid_enum; + if (index = 3) + goto invalid_value; + v-value_int = ctx-Const.MaxComputeWorkGroupCount[index]; + return TYPE_INT; + case GL_MAX_COMPUTE_WORK_GROUP_SIZE: if (!_mesa_is_desktop_gl(ctx) || !ctx-Extensions.ARB_compute_shader) goto invalid_enum;
[Mesa-dev] [PATCH 11/30] mesa: Change redundant code into loops in shaderapi.c.
This is possible now that ctx-Shader.CurrentProgram is an array. --- src/mesa/main/shaderapi.c | 39 +-- 1 file changed, 9 insertions(+), 30 deletions(-) diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index d57748c..61ac0e3 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -130,11 +130,11 @@ _mesa_init_shader_state(struct gl_context *ctx) void _mesa_free_shader_state(struct gl_context *ctx) { - _mesa_reference_shader_program(ctx, ctx-Shader.CurrentProgram[MESA_SHADER_VERTEX], NULL); - _mesa_reference_shader_program(ctx, ctx-Shader.CurrentProgram[MESA_SHADER_GEOMETRY], - NULL); - _mesa_reference_shader_program(ctx, ctx-Shader.CurrentProgram[MESA_SHADER_FRAGMENT], - NULL); + int i; + for (i = 0; i MESA_SHADER_STAGES; i++) { + _mesa_reference_shader_program(ctx, ctx-Shader.CurrentProgram[i], + NULL); + } _mesa_reference_shader_program(ctx, ctx-Shader._CurrentFragmentProgram, NULL); _mesa_reference_shader_program(ctx, ctx-Shader.ActiveProgram, NULL); @@ -946,32 +946,11 @@ use_shader_program(struct gl_context *ctx, GLenum type, struct gl_shader_program *shProg) { struct gl_shader_program **target; + gl_shader_stage stage = _mesa_shader_enum_to_shader_stage(type); - switch (type) { - case GL_VERTEX_SHADER: - target = ctx-Shader.CurrentProgram[MESA_SHADER_VERTEX]; - if ((shProg == NULL) - || (shProg-_LinkedShaders[MESA_SHADER_VERTEX] == NULL)) { -shProg = NULL; - } - break; - case GL_GEOMETRY_SHADER_ARB: - target = ctx-Shader.CurrentProgram[MESA_SHADER_GEOMETRY]; - if ((shProg == NULL) - || (shProg-_LinkedShaders[MESA_SHADER_GEOMETRY] == NULL)) { -shProg = NULL; - } - break; - case GL_FRAGMENT_SHADER: - target = ctx-Shader.CurrentProgram[MESA_SHADER_FRAGMENT]; - if ((shProg == NULL) - || (shProg-_LinkedShaders[MESA_SHADER_FRAGMENT] == NULL)) { -shProg = NULL; - } - break; - default: - return; - } + target = ctx-Shader.CurrentProgram[stage]; + if ((shProg == NULL) || (shProg-_LinkedShaders[stage] == NULL)) + shProg = NULL; if (*target != shProg) { FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS); -- 1.8.5.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 22/30] mesa/cs: Implement MAX_COMPUTE_WORK_GROUP_INVOCATIONS constant.
--- src/glsl/main.cpp | 1 + src/glsl/standalone_scaffolding.cpp | 1 + src/mesa/main/context.c | 1 + src/mesa/main/get.c | 1 + src/mesa/main/get_hash_params.py| 3 +++ src/mesa/main/mtypes.h | 1 + 6 files changed, 8 insertions(+) diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp index bb2054f..94bc1cc 100644 --- a/src/glsl/main.cpp +++ b/src/glsl/main.cpp @@ -53,6 +53,7 @@ initialize_context(struct gl_context *ctx, gl_api api) ctx-Const.MaxComputeWorkGroupSize[0] = 1024; ctx-Const.MaxComputeWorkGroupSize[1] = 1024; ctx-Const.MaxComputeWorkGroupSize[2] = 64; + ctx-Const.MaxComputeWorkGroupInvocations = 1024; ctx-Const.Program[MESA_SHADER_COMPUTE].MaxTextureImageUnits = 16; ctx-Const.Program[MESA_SHADER_COMPUTE].MaxUniformComponents = 1024; ctx-Const.Program[MESA_SHADER_COMPUTE].MaxInputComponents = 0; /* not used */ diff --git a/src/glsl/standalone_scaffolding.cpp b/src/glsl/standalone_scaffolding.cpp index e8eb529..0c83ea3 100644 --- a/src/glsl/standalone_scaffolding.cpp +++ b/src/glsl/standalone_scaffolding.cpp @@ -143,6 +143,7 @@ void initialize_context_to_defaults(struct gl_context *ctx, gl_api api) ctx-Const.MaxComputeWorkGroupSize[0] = 1024; ctx-Const.MaxComputeWorkGroupSize[1] = 1024; ctx-Const.MaxComputeWorkGroupSize[2] = 64; + ctx-Const.MaxComputeWorkGroupInvocations = 1024; ctx-Const.Program[MESA_SHADER_COMPUTE].MaxTextureImageUnits = 16; ctx-Const.Program[MESA_SHADER_COMPUTE].MaxUniformComponents = 1024; ctx-Const.Program[MESA_SHADER_COMPUTE].MaxInputComponents = 0; /* not used */ diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index ebe27b4..942f247 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -695,6 +695,7 @@ _mesa_init_constants(struct gl_context *ctx) ctx-Const.MaxComputeWorkGroupSize[0] = 1024; ctx-Const.MaxComputeWorkGroupSize[1] = 1024; ctx-Const.MaxComputeWorkGroupSize[2] = 64; + ctx-Const.MaxComputeWorkGroupInvocations = 1024; } diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index 6b914f4..bcbb5d5 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -382,6 +382,7 @@ EXTRA_EXT(ARB_texture_multisample); EXTRA_EXT(ARB_texture_gather); EXTRA_EXT(ARB_shader_atomic_counters); EXTRA_EXT(ARB_draw_indirect); +EXTRA_EXT(ARB_compute_shader); static const int extra_ARB_color_buffer_float_or_glcore[] = { diff --git a/src/mesa/main/get_hash_params.py b/src/mesa/main/get_hash_params.py index 7f025a9..c18e848 100644 --- a/src/mesa/main/get_hash_params.py +++ b/src/mesa/main/get_hash_params.py @@ -742,6 +742,9 @@ descriptor=[ # GL_ARB_vertex_attrib_binding [ MAX_VERTEX_ATTRIB_RELATIVE_OFFSET, CONTEXT_ENUM(Const.MaxVertexAttribRelativeOffset), NO_EXTRA ], [ MAX_VERTEX_ATTRIB_BINDINGS, CONTEXT_ENUM(Const.MaxVertexAttribBindings), NO_EXTRA ], + +# GL_ARB_compute_shader + [ MAX_COMPUTE_WORK_GROUP_INVOCATIONS, CONTEXT_ENUM(Const.MaxComputeWorkGroupInvocations), extra_ARB_compute_shader ], ]}, # Enums restricted to OpenGL Core profile diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index d3f3a30..6481dc1 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -3323,6 +3323,7 @@ struct gl_constants /** GL_ARB_compute_shader */ GLuint MaxComputeWorkGroupSize[3]; + GLuint MaxComputeWorkGroupInvocations; }; -- 1.8.5.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 24/30] glsl/cs: Handle compute shader local_size_{x, y, z} declaration.
--- src/glsl/ast.h | 34 +++ src/glsl/ast_to_hir.cpp | 79 ++ src/glsl/ast_type.cpp | 14 ++ src/glsl/builtin_variables.cpp | 20 + src/glsl/glsl_lexer.ll | 3 +- src/glsl/glsl_parser.yy | 94 - src/glsl/glsl_parser_extras.cpp | 51 -- src/glsl/glsl_parser_extras.h | 15 +++ src/mesa/main/mtypes.h | 11 + 9 files changed, 285 insertions(+), 36 deletions(-) diff --git a/src/glsl/ast.h b/src/glsl/ast.h index 76911f0..fa00d75 100644 --- a/src/glsl/ast.h +++ b/src/glsl/ast.h @@ -414,6 +414,12 @@ struct ast_type_qualifier { unsigned prim_type:1; unsigned max_vertices:1; /** \} */ + + /** + * local_size_{x,y,z} flags for compute shaders. Bit 0 represents + * local_size_x, and so on. + */ + unsigned local_size:3; } /** \brief Set of flags, accessed by name. */ q; @@ -464,6 +470,13 @@ struct ast_type_qualifier { int offset; /** +* Local size specified via GL_ARB_compute_shader's local_size_{x,y,z} +* layout qualifier. Element i of this array is only valid if +* flags.q.local_size (1 i) is set. +*/ + int local_size[3]; + + /** * Return true if and only if an interpolation qualifier is present. */ bool has_interpolation() const; @@ -961,6 +974,27 @@ private: const GLenum prim_type; }; + +/** + * AST node representing a decalaration of the input layout for compute + * shaders. + */ +class ast_cs_input_layout : public ast_node +{ +public: + ast_cs_input_layout(const struct YYLTYPE locp, const unsigned *local_size) + { + memcpy(this-local_size, local_size, sizeof(this-local_size)); + set_location(locp); + } + + virtual ir_rvalue *hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state); + +private: + unsigned local_size[3]; +}; + /*@}*/ extern void diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index a26745d..c1b1d6a 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -77,6 +77,7 @@ _mesa_ast_to_hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) state-toplevel_ir = instructions; state-gs_input_prim_type_specified = false; + state-cs_input_local_size_specified = false; /* Section 4.2 of the GLSL 1.20 specification states: * The built-in functions are scoped in a scope outside the global scope @@ -5239,6 +5240,84 @@ ast_gs_input_layout::hir(exec_list *instructions, } +ir_rvalue * +ast_cs_input_layout::hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + YYLTYPE loc = this-get_location(); + + /* If any compute input layout declaration preceded this one, make sure it +* was consistent with this one. +*/ + if (state-cs_input_local_size_specified) { + for (int i = 0; i 3; i++) { + if (state-cs_input_local_size[i] != this-local_size[i]) { +_mesa_glsl_error(loc, state, + compute shader input layout does not match + previous declaration); +return NULL; + } + } + } + + /* From the ARB_compute_shader specification: +* +* If the local size of the shader in any dimension is greater +* than the maximum size supported by the implementation for that +* dimension, a compile-time error results. +* +* It is not clear from the spec how the error should be reported if +* the total size of the work group exceeds +* MAX_COMPUTE_WORK_GROUP_INVOCATIONS, but it seems reasonable to +* report it at compile time as well. +*/ + GLuint64 total_invocations = 1; + for (int i = 0; i 3; i++) { + if (this-local_size[i] state-ctx-Const.MaxComputeWorkGroupSize[i]) { + _mesa_glsl_error(loc, state, + local_size_%c exceeds MAX_COMPUTE_WORK_GROUP_SIZE + (%d), 'x' + i, + state-ctx-Const.MaxComputeWorkGroupSize[i]); + break; + } + total_invocations *= this-local_size[i]; + if (total_invocations + state-ctx-Const.MaxComputeWorkGroupInvocations) { + _mesa_glsl_error(loc, state, + product of local_sizes exceeds + MAX_COMPUTE_WORK_GROUP_INVOCATIONS (%d), + state-ctx-Const.MaxComputeWorkGroupInvocations); + break; + } + } + + state-cs_input_local_size_specified = true; + for (int i = 0; i 3; i++) + state-cs_input_local_size[i] = this-local_size[i]; + + /* We may now declare the built-in constant gl_WorkGroupSize (see +* builtin_variable_generator::generate_constants() for why we didn't +* declare it earlier). +*/ + ir_variable *var
[Mesa-dev] [PATCH 26/30] main/cs: Implement query for COMPUTE_WORK_GROUP_SIZE.
--- src/mesa/main/shaderapi.c | 18 ++ 1 file changed, 18 insertions(+) diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index 053f27b..680d449 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -663,6 +663,24 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname, GLint *param *params = shProg-NumAtomicBuffers; return; + case GL_COMPUTE_WORK_GROUP_SIZE: { + int i; + if (!_mesa_is_desktop_gl(ctx) || !ctx-Extensions.ARB_compute_shader) + break; + if (!shProg-LinkStatus) { + _mesa_error(ctx, GL_INVALID_OPERATION, glGetProgramiv(program not + linked successfully)); + return; + } + if (shProg-_LinkedShaders[MESA_SHADER_COMPUTE] == NULL) { + _mesa_error(ctx, GL_INVALID_OPERATION, glGetProgramiv(no compute + shaders)); + return; + } + for (i = 0; i 3; i++) + params[i] = shProg-Comp.LocalSize[i]; + return; + } default: break; } -- 1.8.5.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 04/30] mesa: use _mesa_validate_shader_target() more frequently.
This patch replaces code in _mesa_new_shader() and delete_shader_cb() that checks the type of a shader with calls to _mesa_validate_shader_target(). This has two advantages: it allows for a more thorough check (since _mesa_validate_shader_target() doesn't permit shader targets that aren't supported by the back-end), and it reduces the amount of code that will need to be modified when adding new shader stages. --- src/mesa/main/shaderobj.c | 4 ++-- src/mesa/main/shared.c| 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mesa/main/shaderobj.c b/src/mesa/main/shaderobj.c index dc81bbc..4f4bb69 100644 --- a/src/mesa/main/shaderobj.c +++ b/src/mesa/main/shaderobj.c @@ -34,6 +34,7 @@ #include main/context.h #include main/hash.h #include main/mtypes.h +#include main/shaderapi.h #include main/shaderobj.h #include main/uniforms.h #include program/program.h @@ -105,8 +106,7 @@ struct gl_shader * _mesa_new_shader(struct gl_context *ctx, GLuint name, GLenum type) { struct gl_shader *shader; - assert(type == GL_FRAGMENT_SHADER || type == GL_VERTEX_SHADER || - type == GL_GEOMETRY_SHADER_ARB); + assert(_mesa_validate_shader_target(ctx, type)); shader = rzalloc(NULL, struct gl_shader); if (shader) { shader-Type = type; diff --git a/src/mesa/main/shared.c b/src/mesa/main/shared.c index 2f73cf3..c11c7f9 100644 --- a/src/mesa/main/shared.c +++ b/src/mesa/main/shared.c @@ -38,6 +38,7 @@ #include dlist.h #include samplerobj.h #include set.h +#include shaderapi.h #include shaderobj.h #include syncobj.h @@ -218,8 +219,7 @@ delete_shader_cb(GLuint id, void *data, void *userData) { struct gl_context *ctx = (struct gl_context *) userData; struct gl_shader *sh = (struct gl_shader *) data; - if (sh-Type == GL_FRAGMENT_SHADER || sh-Type == GL_VERTEX_SHADER || - sh-Type == GL_GEOMETRY_SHADER) { + if (_mesa_validate_shader_target(ctx, sh-Type)) { ctx-Driver.DeleteShader(ctx, sh); } else { -- 1.8.5.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 30/30] i965/cs: Allow ARB_compute_shader to be enabled via env var.
This will allow testing of compute shader functionality before it is completed. To enable ARB_compute_shader functionality in the i965 driver, set INTEL_COMPUTE_SHADER=1. --- src/mesa/drivers/dri/i965/brw_context.c | 11 ++- src/mesa/drivers/dri/i965/intel_extensions.c | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index 1b42751..76dd9be 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -298,10 +298,17 @@ brw_initialize_context_constants(struct brw_context *brw) ctx-Const.Program[MESA_SHADER_GEOMETRY].MaxTextureImageUnits = BRW_MAX_TEX_UNIT; else ctx-Const.Program[MESA_SHADER_GEOMETRY].MaxTextureImageUnits = 0; + if (getenv(INTEL_COMPUTE_SHADER)) { + ctx-Const.Program[MESA_SHADER_COMPUTE].MaxTextureImageUnits = BRW_MAX_TEX_UNIT; + ctx-Const.MaxUniformBufferBindings += 12; + } else { + ctx-Const.Program[MESA_SHADER_COMPUTE].MaxTextureImageUnits = 0; + } ctx-Const.MaxCombinedTextureImageUnits = ctx-Const.Program[MESA_SHADER_VERTEX].MaxTextureImageUnits + ctx-Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits + - ctx-Const.Program[MESA_SHADER_GEOMETRY].MaxTextureImageUnits; + ctx-Const.Program[MESA_SHADER_GEOMETRY].MaxTextureImageUnits + + ctx-Const.Program[MESA_SHADER_COMPUTE].MaxTextureImageUnits; ctx-Const.MaxTextureLevels = 14; /* 8192 */ if (ctx-Const.MaxTextureLevels MAX_TEXTURE_LEVELS) @@ -425,9 +432,11 @@ brw_initialize_context_constants(struct brw_context *brw) ctx-Const.Program[MESA_SHADER_FRAGMENT].MaxAtomicCounters = MAX_ATOMIC_COUNTERS; ctx-Const.Program[MESA_SHADER_VERTEX].MaxAtomicCounters = MAX_ATOMIC_COUNTERS; ctx-Const.Program[MESA_SHADER_GEOMETRY].MaxAtomicCounters = MAX_ATOMIC_COUNTERS; + ctx-Const.Program[MESA_SHADER_COMPUTE].MaxAtomicCounters = MAX_ATOMIC_COUNTERS; ctx-Const.Program[MESA_SHADER_FRAGMENT].MaxAtomicBuffers = BRW_MAX_ABO; ctx-Const.Program[MESA_SHADER_VERTEX].MaxAtomicBuffers = BRW_MAX_ABO; ctx-Const.Program[MESA_SHADER_GEOMETRY].MaxAtomicBuffers = BRW_MAX_ABO; + ctx-Const.Program[MESA_SHADER_COMPUTE].MaxAtomicBuffers = BRW_MAX_ABO; ctx-Const.MaxCombinedAtomicBuffers = 3 * BRW_MAX_ABO; } diff --git a/src/mesa/drivers/dri/i965/intel_extensions.c b/src/mesa/drivers/dri/i965/intel_extensions.c index de07b7f..27bc97b 100644 --- a/src/mesa/drivers/dri/i965/intel_extensions.c +++ b/src/mesa/drivers/dri/i965/intel_extensions.c @@ -294,6 +294,8 @@ intelInitExtensions(struct gl_context *ctx) ctx-Extensions.ARB_transform_feedback_instanced = true; ctx-Extensions.ARB_draw_indirect = true; } + if (getenv(INTEL_COMPUTE_SHADER)) + ctx-Extensions.ARB_compute_shader = true; } if (brw-gen == 5 || can_write_oacontrol(brw)) -- 1.8.5.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 13/30] mesa/cs: Add extension enable flags for ARB_compute_shader.
--- src/glsl/glcpp/glcpp-parse.y| 3 +++ src/glsl/glsl_parser_extras.cpp | 1 + src/glsl/glsl_parser_extras.h | 2 ++ src/glsl/standalone_scaffolding.cpp | 1 + src/mesa/main/extensions.c | 1 + src/mesa/main/mtypes.h | 1 + 6 files changed, 9 insertions(+) diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y index 55c4981..359bcea 100644 --- a/src/glsl/glcpp/glcpp-parse.y +++ b/src/glsl/glcpp/glcpp-parse.y @@ -1284,6 +1284,9 @@ glcpp_parser_create (const struct gl_extensions *extensions, int api) if (extensions-AMD_shader_trinary_minmax) add_builtin_define(parser, GL_AMD_shader_trinary_minmax, 1); + + if (extensions-ARB_compute_shader) + add_builtin_define(parser, GL_ARB_compute_shader, 1); } } diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp index 21dc3ab..33a43c5 100644 --- a/src/glsl/glsl_parser_extras.cpp +++ b/src/glsl/glsl_parser_extras.cpp @@ -513,6 +513,7 @@ static const _mesa_glsl_extension _mesa_glsl_supported_extensions[] = { EXT(ARB_shader_atomic_counters, true, false, ARB_shader_atomic_counters), EXT(ARB_sample_shading, true, false, ARB_sample_shading), EXT(AMD_shader_trinary_minmax, true, false, dummy_true), + EXT(ARB_compute_shader, true, false, ARB_compute_shader), }; #undef EXT diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h index 2444a96..468707c 100644 --- a/src/glsl/glsl_parser_extras.h +++ b/src/glsl/glsl_parser_extras.h @@ -352,6 +352,8 @@ struct _mesa_glsl_parse_state { bool ARB_shader_atomic_counters_warn; bool AMD_shader_trinary_minmax_enable; bool AMD_shader_trinary_minmax_warn; + bool ARB_compute_shader_enable; + bool ARB_compute_shader_warn; /*@}*/ /** Extensions supported by the OpenGL implementation. */ diff --git a/src/glsl/standalone_scaffolding.cpp b/src/glsl/standalone_scaffolding.cpp index 257d2e7..fe66067 100644 --- a/src/glsl/standalone_scaffolding.cpp +++ b/src/glsl/standalone_scaffolding.cpp @@ -91,6 +91,7 @@ void initialize_context_to_defaults(struct gl_context *ctx, gl_api api) ctx-Extensions.dummy_false = false; ctx-Extensions.dummy_true = true; + ctx-Extensions.ARB_compute_shader = true; ctx-Extensions.ARB_conservative_depth = true; ctx-Extensions.ARB_draw_instanced = true; ctx-Extensions.ARB_ES2_compatibility = true; diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index efda548..fb95550 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -84,6 +84,7 @@ static const struct extension extension_table[] = { { GL_ARB_blend_func_extended, o(ARB_blend_func_extended), GL, 2009 }, { GL_ARB_clear_buffer_object, o(dummy_true), GL, 2012 }, { GL_ARB_color_buffer_float, o(ARB_color_buffer_float), GL, 2004 }, + { GL_ARB_compute_shader, o(ARB_compute_shader), GL, 2012 }, { GL_ARB_copy_buffer, o(dummy_true), GL, 2008 }, { GL_ARB_conservative_depth, o(ARB_conservative_depth), GL, 2011 }, { GL_ARB_debug_output,o(dummy_true), GL, 2009 }, diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index bdd2804..7ba7b10 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -3330,6 +3330,7 @@ struct gl_extensions GLboolean ARB_base_instance; GLboolean ARB_blend_func_extended; GLboolean ARB_color_buffer_float; + GLboolean ARB_compute_shader; GLboolean ARB_conservative_depth; GLboolean ARB_depth_buffer_float; GLboolean ARB_depth_clamp; -- 1.8.5.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 27/30] glsl/cs: Prohibit user-defined ins/outs in compute shaders.
--- src/glsl/ast_to_hir.cpp | 7 +++ 1 file changed, 7 insertions(+) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index c1b1d6a..ed3a4f9 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -2220,6 +2220,13 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, var-data.mode = ir_var_uniform; if (!is_parameter is_varying_var(var, state-stage)) { + /* User-defined ins/outs are not permitted in compute shaders. */ + if (state-stage == MESA_SHADER_COMPUTE) { + _mesa_glsl_error(loc, state, + user-defined input and output variables are not + permitted in compute shaders); + } + /* This variable is being used to link data between shader stages (in * pre-glsl-1.30 parlance, it's a varying). Check that it has a type * that is allowed for such purposes. -- 1.8.5.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 2/2] i965: Fix clears of layered framebuffers with mismatched layer counts.
On 9 January 2014 18:19, Chris Forbes chr...@ijw.co.nz wrote: I'm not convinced this is correct/safe, at least for the meta clear. The GL 3.2 spec says, on page 221 (page 235 of the PDF): * If the number of layers of each attachment are not all identical, rendering will be limited to the smallest number of layers of any attachment. And then in the description of layered framebuffers on page 240 (page 254 of the PDF): If the fragment’s layer number is negative, or greater than the minimum number of layers of any attachment, the effects of the fragment on the framebuffer contents are undefined. Blorp clears can obviously do whatever they like, since they don't directly use the user's framebuffer configuration. Yeah, there was some discussion about that here: http://lists.freedesktop.org/archives/mesa-dev/2013-December/049492.html Basically, my justification for doing it this way is that even though it's undefined by GL what happens when you write to a layer that doesn't exist in all attachments, we know that it works in i965, and i965 is the only user of this code (it's the only back-end that supports layered framebuffers and uses Meta). In fact, I would venture to say that i965 is likely to be the only user of this code for the forseeable future, since the only other back-end that uses Meta is the i915 driver, and it's never going to be capable of supporting layered framebuffers. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 2/2] i965: Fix clears of layered framebuffers with mismatched layer counts.
OK, in that case: Reviewed-by: Chris Forbes chr...@ijw.co.nz On Fri, Jan 10, 2014 at 3:42 PM, Paul Berry stereotype...@gmail.com wrote: On 9 January 2014 18:19, Chris Forbes chr...@ijw.co.nz wrote: I'm not convinced this is correct/safe, at least for the meta clear. The GL 3.2 spec says, on page 221 (page 235 of the PDF): * If the number of layers of each attachment are not all identical, rendering will be limited to the smallest number of layers of any attachment. And then in the description of layered framebuffers on page 240 (page 254 of the PDF): If the fragment’s layer number is negative, or greater than the minimum number of layers of any attachment, the effects of the fragment on the framebuffer contents are undefined. Blorp clears can obviously do whatever they like, since they don't directly use the user's framebuffer configuration. Yeah, there was some discussion about that here: http://lists.freedesktop.org/archives/mesa-dev/2013-December/049492.html Basically, my justification for doing it this way is that even though it's undefined by GL what happens when you write to a layer that doesn't exist in all attachments, we know that it works in i965, and i965 is the only user of this code (it's the only back-end that supports layered framebuffers and uses Meta). In fact, I would venture to say that i965 is likely to be the only user of this code for the forseeable future, since the only other back-end that uses Meta is the i915 driver, and it's never going to be capable of supporting layered framebuffers. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] gallium: add bits for clipping points as tris (d3d-style)
From: Roland Scheidegger srol...@vmware.com OpenGL does whole-point clipping, that is a large point is either fully clipped or fully unclipped (the latter means it may extend beyond the viewport as long as the center is inside the viewport). d3d9 (d3d10 has no large points) however requires points to be clipped after they are expanded to a rectangle. (Note some IHVs are known to ignore GL rules at least with some hw/drivers.) Hence add a rasterizer bit indicating which way points should be clipped (some drivers probably will always ignore this), and add the draw interaction this requires. Drivers wanting to support this and using draw must support large points on their own as draw doesn't implement vp clipping on the expanded points (it potentially could but the complexity doesn't seem warranted), and the driver needs to do viewport scissoring on such points. Conflicts: src/gallium/drivers/llvmpipe/lp_context.c src/gallium/drivers/llvmpipe/lp_state_derived.c --- src/gallium/auxiliary/draw/draw_context.c | 12 +++- src/gallium/auxiliary/draw/draw_context.h |3 +- src/gallium/auxiliary/draw/draw_pipe_clip.c| 31 ++-- src/gallium/auxiliary/draw/draw_private.h |2 ++ .../auxiliary/draw/draw_pt_fetch_shade_pipeline.c |3 +- .../draw/draw_pt_fetch_shade_pipeline_llvm.c |3 +- src/gallium/docs/source/cso/rasterizer.rst | 15 +++--- src/gallium/drivers/svga/svga_swtnl_draw.c |2 +- src/gallium/include/pipe/p_state.h |1 + 9 files changed, 60 insertions(+), 12 deletions(-) diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c index 2b3bc0d..9b5bcb5 100644 --- a/src/gallium/auxiliary/draw/draw_context.c +++ b/src/gallium/auxiliary/draw/draw_context.c @@ -262,6 +262,10 @@ static void update_clip_flags( struct draw_context *draw ) draw-rasterizer draw-rasterizer-depth_clip); draw-clip_user = draw-rasterizer draw-rasterizer-clip_plane_enable != 0; + draw-clip_points_xy = draw-clip_xy + (!draw-driver.bypass_clip_points || + (draw-rasterizer + !draw-rasterizer-point_tri_clip)); } /** @@ -287,17 +291,23 @@ void draw_set_rasterizer_state( struct draw_context *draw, * Some hardware can turn off clipping altogether - in particular any * hardware with a TNL unit can do its own clipping, even if it is * relying on the draw module for some other reason. + * Setting bypass_clip_points to achieve d3d-style point clipping (the driver + * will need to do the vp scissoring) _requires_ the driver to implement + * wide points / point sprites itself (points will still be clipped if rasterizer + * point_tri_clip isn't set). Only relevant if bypass_clip_xy isn't set. */ void draw_set_driver_clipping( struct draw_context *draw, boolean bypass_clip_xy, boolean bypass_clip_z, - boolean guard_band_xy) + boolean guard_band_xy, + boolean bypass_clip_points) { draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE ); draw-driver.bypass_clip_xy = bypass_clip_xy; draw-driver.bypass_clip_z = bypass_clip_z; draw-driver.guard_band_xy = guard_band_xy; + draw-driver.bypass_clip_points = bypass_clip_points; update_clip_flags(draw); } diff --git a/src/gallium/auxiliary/draw/draw_context.h b/src/gallium/auxiliary/draw/draw_context.h index e2e0cb4..65716c9 100644 --- a/src/gallium/auxiliary/draw/draw_context.h +++ b/src/gallium/auxiliary/draw/draw_context.h @@ -263,7 +263,8 @@ void draw_set_render( struct draw_context *draw, void draw_set_driver_clipping( struct draw_context *draw, boolean bypass_clip_xy, boolean bypass_clip_z, - boolean guard_band_xy); + boolean guard_band_xy, + boolean bypass_clip_points); void draw_set_force_passthrough( struct draw_context *draw, boolean enable ); diff --git a/src/gallium/auxiliary/draw/draw_pipe_clip.c b/src/gallium/auxiliary/draw/draw_pipe_clip.c index dbb6757..adfa4b6 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_clip.c +++ b/src/gallium/auxiliary/draw/draw_pipe_clip.c @@ -609,12 +609,37 @@ do_clip_line( struct draw_stage *stage, static void clip_point( struct draw_stage *stage, - struct prim_header *header ) +struct prim_header *header ) { - if (header-v[0]-clipmask == 0) + if (header-v[0]-clipmask == 0) stage-next-point( stage-next, header ); } +/* + * Clip points but ignore the first 4 (xy) clip planes. + * (This is necessary because we don't generate a different shader
Re: [Mesa-dev] [PATCH 1/2] loader: refactor duplicated code into loader util lib
Rob Clark robdcl...@gmail.com writes: From: Rob Clark robcl...@freedesktop.org All the various window system integration layers duplicate roughly the same code for figuring out device and driver name, pci-id's, etc. Which is sad. So extract it out into a loader util lib. Thanks for tackling this. It had been (low) on my list for a while. static int droid_open_device(void) { @@ -773,7 +672,7 @@ dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *dpy) goto cleanup_display; } forgot loader_set_logger here. Do we want to just move that to egl_dri2.c instead of each platform_*? - dri2_dpy-driver_name = (char *) droid_get_driver_name(dri2_dpy-fd); + dri2_dpy-driver_name = loader_get_driver_for_fd(dri2_dpy-fd, 0); if (dri2_dpy-driver_name == NULL) { err = DRI2: failed to get driver name; goto cleanup_device; diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader.h b/src/gallium/auxiliary/pipe-loader/pipe_loader.h index 444bdf1..e915c63 100644 --- a/src/gallium/auxiliary/pipe-loader/pipe_loader.h +++ b/src/gallium/auxiliary/pipe-loader/pipe_loader.h @@ -44,6 +44,7 @@ struct pipe_screen; enum pipe_loader_device_type { PIPE_LOADER_DEVICE_SOFTWARE, PIPE_LOADER_DEVICE_PCI, + PIPE_LOADER_DEVICE_PLATFORM, NUM_PIPE_LOADER_DEVICE_TYPES }; diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c index 927fb24..fda0ab1 100644 --- a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c +++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c @@ -190,17 +117,22 @@ boolean pipe_loader_drm_probe_fd(struct pipe_loader_device **dev, int fd) { struct pipe_loader_drm_device *ddev = CALLOC_STRUCT(pipe_loader_drm_device); - - ddev-base.type = PIPE_LOADER_DEVICE_PCI; + int vendor_id, chip_id; + + if (loader_get_pci_id_for_fd(fd, vendor_id, chip_id)) { + ddev-base.type = PIPE_LOADER_DEVICE_PCI; + ddev-base.u.pci.vendor_id = vendor_id; + ddev-base.u.pci.chip_id = chip_id; + } else { + ddev-base.type = PIPE_LOADER_DEVICE_PLATFORM; + } ddev-base.ops = pipe_loader_drm_ops; ddev-fd = fd; pipe_loader_drm_x_auth(fd); - if (!find_drm_pci_id(ddev)) - goto fail; - - if (!find_drm_driver_name(ddev)) + ddev-base.driver_name = loader_get_driver_for_fd(fd, _LOADER_GALLIUM); + if (!ddev-base.driver_name) goto fail; *dev = ddev-base; diff --git a/src/gallium/state_trackers/clover/core/device.cpp b/src/gallium/state_trackers/clover/core/device.cpp index e5e429a..76a49d0 100644 --- a/src/gallium/state_trackers/clover/core/device.cpp +++ b/src/gallium/state_trackers/clover/core/device.cpp @@ -63,6 +63,7 @@ device::type() const { case PIPE_LOADER_DEVICE_SOFTWARE: return CL_DEVICE_TYPE_CPU; case PIPE_LOADER_DEVICE_PCI: + case PIPE_LOADER_DEVICE_PLATFORM: return CL_DEVICE_TYPE_GPU; default: assert(0); @@ -74,6 +75,7 @@ cl_uint device::vendor_id() const { switch (ldev-type) { case PIPE_LOADER_DEVICE_SOFTWARE: + case PIPE_LOADER_DEVICE_PLATFORM: return 0; case PIPE_LOADER_DEVICE_PCI: return ldev-u.pci.vendor_id; These hunks look unrelated to the refactor and should be in a separate commit enabling non-pci devices. diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c index b4b97ac..c13930c 100644 --- a/src/gbm/backends/dri/gbm_dri.c +++ b/src/gbm/backends/dri/gbm_dri.c @@ -44,6 +44,7 @@ #include gbm_driint.h #include gbmint.h +#include loader.h /* For importing wl_buffer */ #if HAVE_WAYLAND_PLATFORM @@ -270,7 +271,7 @@ dri_screen_create(struct gbm_dri_device *dri) const __DRIextension **extensions; int ret = 0; - dri-base.driver_name = dri_fd_get_driver_name(dri-base.base.fd); + dri-base.driver_name = loader_get_driver_for_fd(dri-base.base.fd, 0); if (dri-base.driver_name == NULL) return -1; Another missing set_logger. diff --git a/src/loader/loader.c b/src/loader/loader.c new file mode 100644 index 000..3e69a59 --- /dev/null +++ b/src/loader/loader.c @@ -0,0 +1,264 @@ +/* + * Copyright (C) 2013 Rob Clark robcl...@freedesktop.org + * + * 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
Re: [Mesa-dev] [PATCH 2/2] loader: fallback to drmGetVersion() for non-pci devices
Rob Clark robdcl...@gmail.com writes: From: Rob Clark robcl...@freedesktop.org Use the driver name from drmGetVersion() for non-pci devices. Seems like a reasonable thing to do. Might just make it clear in the commit message that you're using the kernel driver name, not the userspace driver name. Reviewed-by: Eric Anholt e...@anholt.net pgpsE_vqqrBp2.pgp Description: PGP signature ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 03/10] i965: Create a helper function for emitting PIPE_CONTROL flushes.
Kenneth Graunke kenn...@whitecape.org writes: These days, we need to emit PIPE_CONTROL flushes all over the place. Being able to do that via a single function call seems convenient. Broadwell will also increase the length of these packets by 1; with the refactoring, we should have to do this in substantially fewer places. Signed-off-by: Kenneth Graunke kenn...@whitecape.org diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.c b/src/mesa/drivers/dri/i965/intel_batchbuffer.c index d9b6c15..d2f0e90 100644 --- a/src/mesa/drivers/dri/i965/intel_batchbuffer.c +++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.c @@ -475,6 +475,32 @@ emit: } /** + * Emit a PIPE_CONTROL with various flushing flags. + * + * The caller is responsible for deciding what flags are appropriate for the + * given generation. + */ +void +brw_emit_pipe_control_flush(struct brw_context *brw, uint32_t flags) +{ + if (brw-gen = 6) { + BEGIN_BATCH(4); + OUT_BATCH(_3DSTATE_PIPE_CONTROL | (4 - 2)); + OUT_BATCH(flags); + OUT_BATCH(0); + OUT_BATCH(0); + ADVANCE_BATCH(); + } else { + BEGIN_BATCH(4); + OUT_BATCH(_3DSTATE_PIPE_CONTROL | flags | (4 - 2)); + OUT_BATCH(0); + OUT_BATCH(0); + OUT_BATCH(0); + ADVANCE_BATCH(); + } +} + +/** * Restriction [DevSNB, DevIVB]: * * Prior to changing Depth/Stencil Buffer state (i.e. any combination of @@ -491,26 +517,9 @@ intel_emit_depth_stall_flushes(struct brw_context *brw) { assert(brw-gen = 6 brw-gen = 7); - BEGIN_BATCH(4); - OUT_BATCH(_3DSTATE_PIPE_CONTROL | (4 - 2)); - OUT_BATCH(PIPE_CONTROL_DEPTH_STALL); - OUT_BATCH(0); /* address */ - OUT_BATCH(0); /* write data */ - ADVANCE_BATCH() - - BEGIN_BATCH(4); - OUT_BATCH(_3DSTATE_PIPE_CONTROL | (4 - 2)); - OUT_BATCH(PIPE_CONTROL_DEPTH_CACHE_FLUSH); - OUT_BATCH(0); /* address */ - OUT_BATCH(0); /* write data */ - ADVANCE_BATCH(); - - BEGIN_BATCH(4); - OUT_BATCH(_3DSTATE_PIPE_CONTROL | (4 - 2)); - OUT_BATCH(PIPE_CONTROL_DEPTH_STALL); - OUT_BATCH(0); /* address */ - OUT_BATCH(0); /* write data */ - ADVANCE_BATCH(); + brw_emit_pipe_control_flush(brw, PIPE_CONTROL_DEPTH_STALL); + brw_emit_pipe_control_flush(brw, PIPE_CONTROL_DEPTH_CACHE_FLUSH); + brw_emit_pipe_control_flush(brw, PIPE_CONTROL_DEPTH_STALL); } /** @@ -608,13 +617,8 @@ intel_emit_post_sync_nonzero_flush(struct brw_context *brw) if (!brw-batch.need_workaround_flush) return; - BEGIN_BATCH(4); - OUT_BATCH(_3DSTATE_PIPE_CONTROL | (4 - 2)); - OUT_BATCH(PIPE_CONTROL_CS_STALL | - PIPE_CONTROL_STALL_AT_SCOREBOARD); - OUT_BATCH(0); /* address */ - OUT_BATCH(0); /* write data */ - ADVANCE_BATCH(); + brw_emit_pipe_control_flush(brw, PIPE_CONTROL_CS_STALL | + PIPE_CONTROL_STALL_AT_SCOREBOARD); BEGIN_BATCH(4); OUT_BATCH(_3DSTATE_PIPE_CONTROL | (4 - 2)); @@ -636,46 +640,22 @@ intel_emit_post_sync_nonzero_flush(struct brw_context *brw) void intel_batchbuffer_emit_mi_flush(struct brw_context *brw) { - if (brw-gen = 6) { - if (brw-batch.ring == BLT_RING) { - BEGIN_BATCH_BLT(4); - OUT_BATCH(MI_FLUSH_DW); - OUT_BATCH(0); - OUT_BATCH(0); - OUT_BATCH(0); - ADVANCE_BATCH(); - } else { - if (brw-gen == 6) { - /* Hardware workaround: SNB B-Spec says: - * - * [Dev-SNB{W/A}]: Before a PIPE_CONTROL with Write Cache - * Flush Enable =1, a PIPE_CONTROL with any non-zero - * post-sync-op is required. - */ - intel_emit_post_sync_nonzero_flush(brw); - } - - BEGIN_BATCH(4); - OUT_BATCH(_3DSTATE_PIPE_CONTROL | (4 - 2)); - OUT_BATCH(PIPE_CONTROL_INSTRUCTION_FLUSH | -PIPE_CONTROL_WRITE_FLUSH | -PIPE_CONTROL_DEPTH_CACHE_FLUSH | - PIPE_CONTROL_VF_CACHE_INVALIDATE | -PIPE_CONTROL_TC_FLUSH | -PIPE_CONTROL_NO_WRITE | - PIPE_CONTROL_CS_STALL); - OUT_BATCH(0); /* write address */ - OUT_BATCH(0); /* write data */ - ADVANCE_BATCH(); - } - } else { - BEGIN_BATCH(4); - OUT_BATCH(_3DSTATE_PIPE_CONTROL | (4 - 2) | - PIPE_CONTROL_WRITE_FLUSH | - PIPE_CONTROL_NO_WRITE); - OUT_BATCH(0); /* write address */ - OUT_BATCH(0); /* write data */ - OUT_BATCH(0); /* write data */ + if (unlikely(brw-batch.ring == BLT_RING) brw-gen = 6) { + BEGIN_BATCH_BLT(4); + OUT_BATCH(MI_FLUSH_DW); + OUT_BATCH(0); + OUT_BATCH(0); + OUT_BATCH(0); ADVANCE_BATCH(); This shouldn't be marked unlikely. You should use unlikely for this path should be never executed in a performance-sensitive way, not just I bet this will be used a bit less frequently than the alternative. (the compiler does more than
Re: [Mesa-dev] [PATCH 05/10] i965: Use Global GTT for Sandybridge post-sync non-zero workaround.
Kenneth Graunke kenn...@whitecape.org writes: The kernel doesn't even set up the aliasing PPGTT on Sandybridge, so any writes marked as PPGTT will likely just get dropped on the floor. The hardware bug is that writes not marked as GTT are still looked up in the GTT anyway. The kernel does set up the PPGTT, which is how we found we needed to put in the kernel workaround based on DOMAIN_INSTRUCTION (of binding the target buffer to the gtt as well as the ppgtt, since the writes landed in the wrong place) I don't think this patch will change anything, but it seems reasonable if the commit message is updated. pgpO0JO3HnDO_.pgp Description: PGP signature ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 11/30] mesa: Change redundant code into loops in shaderapi.c.
This is a slightly odd construction (although copied from the existing code): + if ((shProg == NULL) || (shProg-_LinkedShaders[stage] == NULL)) +shProg = NULL; ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 08/10] i965: Introduce an OUT_RELOC64 macro.
Kenneth Graunke kenn...@whitecape.org writes: On 12/13/2013 09:28 AM, Daniel Vetter wrote: On Thu, Dec 12, 2013 at 01:26:40AM -0800, Kenneth Graunke wrote: Broadwell uses 48-bit addresses. The first DWord is the low 32 bits, and the second DWord is the high 16 bits. Since individual buffers shouldn't be larger than 4GB in size, any offsets into those buffers (buffer-offset + delta) should fit in the low 32 bits. So I believe we can simply emit 0 for the high 16-bits, and drm_intel_bo_emit_reloc() should patch it up. Signed-off-by: Kenneth Graunke kenn...@whitecape.org --- src/mesa/drivers/dri/i965/intel_batchbuffer.h | 5 + 1 file changed, 5 insertions(+) diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.h b/src/mesa/drivers/dri/i965/intel_batchbuffer.h index 159f928..128eed9 100644 --- a/src/mesa/drivers/dri/i965/intel_batchbuffer.h +++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.h @@ -178,6 +178,11 @@ void intel_batchbuffer_cached_advance(struct brw_context *brw); read_domains, write_domain, delta); \ } while (0) +/* Handle 48-bit address relocations for Gen8+ */ +#define OUT_RELOC64(buf, read_domains, write_domain, delta) \ + OUT_RELOC(buf, read_domains, write_domain, delta); \ + OUT_BATCH(0); Please not. The presumed_offset that libdrm uses is 64bits, and you need to emit the full presumed address (and correctly shifted). Atm the kernel never gives you a presumed reloc offset with the high bits set so it doesn't matter. But I'd prefer if we don't need to make this opt-in behaviour once we enable address spaces with more than 4G. i-g-t gets away with the cheap hack since we're allowed to break igt. Let me check ddx and libva whether I've lost this fight already ... -Daniel I'm more than happy to do the right thing, I just don't know what that is. I don't see any uint64_t values in the interface we use at all: OUT_RELOC becomes ret = drm_intel_bo_emit_reloc(brw-batch.bo, 4*brw-batch.used, buffer, delta, read_domains, write_domain); The libdrm ABI is a disaster. bo-offset is a long, so we're keeping 32 bits of the kernel's returned value on 32 bit userspace, and 64 bits on 64 bit userspace. This means that on 32-bit we'll write in an expected-incorrect offset in the presumed offset for a 4g-located BO, which the kernel will map and fix up at exec time. On 64-bit, your patch would write an expected-incorrect 32-bit value into the batch, but libdrm would tell the kernel the full expected 64 bit value in the presumed_offset field, and you'll get brokenness for 4g buffers. So, I think you do need a drm_intel_bo_emit_reloc64 that returns a uint64_t value that the kernel wrote into the presumed offset, which you then plug into your batchbuffer. (In other news, while thinking about this, there are some obscure races with buffer migration due to presumed_offset being read at a separate time from when we look up bo-offset to actually write the offset into the batch, in the presence of context sharing in GL). pgpgcFjDmr7u0.pgp Description: PGP signature ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] i965/fs: Optimize LRP with x == y into a MOV.
total instructions in shared programs: 1487331 - 1485988 (-0.09%) instructions in affected programs: 45638 - 44295 (-2.94%) GAINED:7 LOST: 0 --- No change from the equivalent vec4 change. src/mesa/drivers/dri/i965/brw_fs.cpp | 10 ++ 1 file changed, 10 insertions(+) diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index ee1b0c2..c2955d6 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -2000,6 +2000,16 @@ fs_visitor::opt_algebraic() break; } break; + case BRW_OPCODE_LRP: + if (inst-src[1].equals(inst-src[2])) { +inst-opcode = BRW_OPCODE_MOV; +inst-src[0] = inst-src[1]; +inst-src[1] = reg_undef; +inst-src[2] = reg_undef; +progress = true; +break; + } + break; case BRW_OPCODE_SEL: if (inst-saturate inst-src[1].file == IMM) { switch (inst-conditional_mod) { -- 1.8.3.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 05/10] i965: Use Global GTT for Sandybridge post-sync non-zero workaround.
Eric Anholt e...@anholt.net writes: Kenneth Graunke kenn...@whitecape.org writes: The kernel doesn't even set up the aliasing PPGTT on Sandybridge, so any writes marked as PPGTT will likely just get dropped on the floor. The hardware bug is that writes not marked as GTT are still looked up in the GTT anyway. The kernel does set up the PPGTT, which is how we found we needed to put in the kernel workaround based on DOMAIN_INSTRUCTION (of binding the target buffer to the gtt as well as the ppgtt, since the writes landed in the wrong place) I don't think this patch will change anything, but it seems reasonable if the commit message is updated. Actually, thinking about it more, I'd rather not explicitly use global GTT, unless the function is also renamed to gen6_emit_post_sync_nonzero_workaround, since now this function on non-gen6 would reference GTT memory in its instruction, but the kernel wouldn't put anything in the GTT. (I'd rather just leave the workaround as is, myself). pgpxX7S1fkLQ3.pgp Description: PGP signature ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 05/30] glsl/linker: Refactor in preparation for adding more shader stages.
This is a nice cleanup; I like that this brings both writes to prog-LastClipDistanceArraySize together -- but it looks like the behavior changes slightly. Previously, if there was no VS and no GS, then we would never write prog-LastClipDistanceArraySize. Now we'll read an old junk value (potentially from a previous linking of the same program object with different shaders attached) from prog-Vert.ClipDistanceArraySize (since we never called validate_vertex_shader_executable) -- but we'll never end up actually using it, since it's only used for transform feedback of gl_ClipDistance. If this is indeed how you intended it to work, and agree that it's completely benign, then patches 1-12 are: Reviewed-by: Chris Forbes chr...@ijw.co.nz On Fri, Jan 10, 2014 at 3:19 PM, Paul Berry stereotype...@gmail.com wrote: Rather than maintain separately named arrays and counts for vertex, geometry, and fragment shaders, just maintain these as arrays indexed by the gl_shader_type enum. --- src/glsl/linker.cpp | 114 ++-- 1 file changed, 39 insertions(+), 75 deletions(-) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index e820f0f..f3fd66f 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -1994,19 +1994,14 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog) /* Separate the shaders into groups based on their type. */ - struct gl_shader **vert_shader_list; - unsigned num_vert_shaders = 0; - struct gl_shader **frag_shader_list; - unsigned num_frag_shaders = 0; - struct gl_shader **geom_shader_list; - unsigned num_geom_shaders = 0; - - vert_shader_list = (struct gl_shader **) - calloc(prog-NumShaders, sizeof(struct gl_shader *)); - frag_shader_list = (struct gl_shader **) - calloc(prog-NumShaders, sizeof(struct gl_shader *)); - geom_shader_list = (struct gl_shader **) - calloc(prog-NumShaders, sizeof(struct gl_shader *)); + struct gl_shader **shader_list[MESA_SHADER_STAGES]; + unsigned num_shaders[MESA_SHADER_STAGES]; + + for (int i = 0; i MESA_SHADER_STAGES; i++) { + shader_list[i] = (struct gl_shader **) + calloc(prog-NumShaders, sizeof(struct gl_shader *)); + num_shaders[i] = 0; + } unsigned min_version = UINT_MAX; unsigned max_version = 0; @@ -2022,20 +2017,9 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog) goto done; } - switch (prog-Shaders[i]-Stage) { - case MESA_SHADER_VERTEX: -vert_shader_list[num_vert_shaders] = prog-Shaders[i]; -num_vert_shaders++; -break; - case MESA_SHADER_FRAGMENT: -frag_shader_list[num_frag_shaders] = prog-Shaders[i]; -num_frag_shaders++; -break; - case MESA_SHADER_GEOMETRY: -geom_shader_list[num_geom_shaders] = prog-Shaders[i]; -num_geom_shaders++; -break; - } + gl_shader_stage shader_type = prog-Shaders[i]-Stage; + shader_list[shader_type][num_shaders[shader_type]] = prog-Shaders[i]; + num_shaders[shader_type]++; } /* In desktop GLSL, different shader versions may be linked together. In @@ -2052,7 +2036,8 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog) /* Geometry shaders have to be linked with vertex shaders. */ - if (num_geom_shaders 0 num_vert_shaders == 0) { + if (num_shaders[MESA_SHADER_GEOMETRY] 0 + num_shaders[MESA_SHADER_VERTEX] == 0) { linker_error(prog, Geometry shader must be linked with vertex shader\n); goto done; @@ -2067,55 +2052,37 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog) /* Link all shaders for a particular stage and validate the result. */ - if (num_vert_shaders 0) { - gl_shader *const sh = -link_intrastage_shaders(mem_ctx, ctx, prog, vert_shader_list, -num_vert_shaders); - - if (!prog-LinkStatus) -goto done; - - validate_vertex_shader_executable(prog, sh); - if (!prog-LinkStatus) -goto done; - prog-LastClipDistanceArraySize = prog-Vert.ClipDistanceArraySize; + for (int stage = 0; stage MESA_SHADER_STAGES; stage++) { + if (num_shaders[stage] 0) { + gl_shader *const sh = +link_intrastage_shaders(mem_ctx, ctx, prog, shader_list[stage], +num_shaders[stage]); - _mesa_reference_shader(ctx, prog-_LinkedShaders[MESA_SHADER_VERTEX], -sh); - } - - if (num_frag_shaders 0) { - gl_shader *const sh = -link_intrastage_shaders(mem_ctx, ctx, prog, frag_shader_list, -num_frag_shaders); - - if (!prog-LinkStatus) -goto done; + if (!prog-LinkStatus) +goto done; -
Re: [Mesa-dev] [PATCH 19/30] mesa/cs: Handle compute shaders in _mesa_use_program().
Minor nit, but could CS be done after the ordered pipeline stages, for consistency? On Fri, Jan 10, 2014 at 3:19 PM, Paul Berry stereotype...@gmail.com wrote: --- src/mesa/main/shaderapi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index 519b200..5188e9c 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -993,6 +993,7 @@ _mesa_use_program(struct gl_context *ctx, struct gl_shader_program *shProg) { use_shader_program(ctx, GL_VERTEX_SHADER, shProg); use_shader_program(ctx, GL_GEOMETRY_SHADER_ARB, shProg); + use_shader_program(ctx, GL_COMPUTE_SHADER, shProg); use_shader_program(ctx, GL_FRAGMENT_SHADER, shProg); _mesa_active_program(ctx, shProg, glUseProgram); -- 1.8.5.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] i965/fs: Optimize LRP with x == y into a MOV.
Reviewed-by: Jordan Justen jordan.l.jus...@intel.com On Thu, Jan 9, 2014 at 8:58 PM, Matt Turner matts...@gmail.com wrote: total instructions in shared programs: 1487331 - 1485988 (-0.09%) instructions in affected programs: 45638 - 44295 (-2.94%) GAINED:7 LOST: 0 --- No change from the equivalent vec4 change. src/mesa/drivers/dri/i965/brw_fs.cpp | 10 ++ 1 file changed, 10 insertions(+) diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index ee1b0c2..c2955d6 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -2000,6 +2000,16 @@ fs_visitor::opt_algebraic() break; } break; + case BRW_OPCODE_LRP: + if (inst-src[1].equals(inst-src[2])) { +inst-opcode = BRW_OPCODE_MOV; +inst-src[0] = inst-src[1]; +inst-src[1] = reg_undef; +inst-src[2] = reg_undef; +progress = true; +break; + } + break; case BRW_OPCODE_SEL: if (inst-saturate inst-src[1].file == IMM) { switch (inst-conditional_mod) { -- 1.8.3.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 01/10] i965: Delete duplicate write_timestamp function.
Kenneth Graunke kenn...@whitecape.org writes: brw_queryobj.c needs a version of write_timestamp that works on all generations for the QueryCounter() driver hook. So there's no point in duplicating it in gen6_queryobj.c. Patches 1, 4, 6, 7, 9, and 10 are: Reviewed-by: Eric Anholt e...@anholt.net Patch 2 landed. Patch 3 is rb with tiny fixes. pgpvrcD5JpfCK.pgp Description: PGP signature ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev