diff options
author | Chris Forbes <[email protected]> | 2012-12-21 21:33:37 +1300 |
---|---|---|
committer | Chris Forbes <[email protected]> | 2013-03-02 11:33:54 +1300 |
commit | ffb53b4f0384fc811372644ce35471c0711eef9e (patch) | |
tree | a9600d8e15d97f25a90cec15db64dce44e3f3e86 /src/glsl/builtins | |
parent | 16af0aca09029e647e4b7ae53ed94b089531c080 (diff) |
glsl: add support for ARB_texture_multisample
V2: - emit `sample` parameter properly for multisample texelFetch()
- fix spurious whitespace change
- introduce a new opcode ir_txf_ms rather than overloading the
existing ir_txf further. This makes doing the right thing in
the driver somewhat simpler.
V3: - fix weird whitespace
V4: - don't forget to include the new opcode in tex_opcode_strs[]
(thanks Kenneth for spotting this)
Signed-off-by: Chris Forbes <[email protected]>
[V2] Reviewed-by: Eric Anholt <[email protected]>
[V2] Reviewed-by: Paul Berry <[email protected]>
Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/glsl/builtins')
-rw-r--r-- | src/glsl/builtins/profiles/ARB_texture_multisample.glsl | 18 | ||||
-rwxr-xr-x | src/glsl/builtins/tools/generate_builtins.py | 1 | ||||
-rwxr-xr-x | src/glsl/builtins/tools/texture_builtins.py | 28 |
3 files changed, 41 insertions, 6 deletions
diff --git a/src/glsl/builtins/profiles/ARB_texture_multisample.glsl b/src/glsl/builtins/profiles/ARB_texture_multisample.glsl new file mode 100644 index 00000000000..4fa67e95e30 --- /dev/null +++ b/src/glsl/builtins/profiles/ARB_texture_multisample.glsl @@ -0,0 +1,18 @@ +#version 130 +#extension GL_ARB_texture_multisample : enable + +ivec2 textureSize( sampler2DMS sampler); +ivec2 textureSize(isampler2DMS sampler); +ivec2 textureSize(usampler2DMS sampler); + +ivec3 textureSize( sampler2DMSArray sampler); +ivec3 textureSize(isampler2DMSArray sampler); +ivec3 textureSize(usampler2DMSArray sampler); + + vec4 texelFetch( sampler2DMS sampler, ivec2 P, int sample); +ivec4 texelFetch(isampler2DMS sampler, ivec2 P, int sample); +uvec4 texelFetch(usampler2DMS sampler, ivec2 P, int sample); + + vec4 texelFetch( sampler2DMSArray sampler, ivec3 P, int sample); +ivec4 texelFetch(isampler2DMSArray sampler, ivec3 P, int sample); +uvec4 texelFetch(usampler2DMSArray sampler, ivec3 P, int sample); diff --git a/src/glsl/builtins/tools/generate_builtins.py b/src/glsl/builtins/tools/generate_builtins.py index 3db862e5f58..6da29c073e9 100755 --- a/src/glsl/builtins/tools/generate_builtins.py +++ b/src/glsl/builtins/tools/generate_builtins.py @@ -190,6 +190,7 @@ read_builtins(GLenum target, const char *protos, const char **functions, unsigne st->ARB_shader_bit_encoding_enable = true; st->ARB_texture_cube_map_array_enable = true; st->ARB_shading_language_packing_enable = true; + st->ARB_texture_multisample_enable = true; _mesa_glsl_initialize_types(st); sh->ir = new(sh) exec_list; diff --git a/src/glsl/builtins/tools/texture_builtins.py b/src/glsl/builtins/tools/texture_builtins.py index 654eb06c888..f32391de9ea 100755 --- a/src/glsl/builtins/tools/texture_builtins.py +++ b/src/glsl/builtins/tools/texture_builtins.py @@ -57,6 +57,12 @@ def get_txs_dim(sampler_type): return 2 return get_coord_dim(sampler_type) +def has_lod(sampler_type): + if 'Buffer' in sampler_type: return False + if 'Rect' in sampler_type: return False + if 'MS' in sampler_type: return False + return True + def generate_sigs(g, tex_inst, sampler_type, variant = 0, unused_fields = 0): coord_dim = get_coord_dim(sampler_type) extra_dim = get_extra_dim(sampler_type, variant & Proj, unused_fields) @@ -74,11 +80,13 @@ def generate_sigs(g, tex_inst, sampler_type, variant = 0, unused_fields = 0): print " (parameters" print " (declare (in) " + g + "sampler" + sampler_type + " sampler)", if tex_inst != "txs": - print "\n (declare (in) " + vec_type("i" if tex_inst == "txf" else "", coord_dim + extra_dim) + " P)", + print "\n (declare (in) " + vec_type("i" if tex_inst in ['txf','txf_ms'] else "", coord_dim + extra_dim) + " P)", if tex_inst == "txl": print "\n (declare (in) float lod)", - elif ((tex_inst == "txf" or tex_inst == "txs") and "Buffer" not in sampler_type and "Rect" not in sampler_type): + elif tex_inst in ['txf', 'txs'] and has_lod(sampler_type): print "\n (declare (in) int lod)", + elif tex_inst == "txf_ms": + print "\n (declare (in) int sample)", elif tex_inst == "txd": grad_type = vec_type("", sampler_dim) print "\n (declare (in) " + grad_type + " dPdx)", @@ -100,12 +108,14 @@ def generate_sigs(g, tex_inst, sampler_type, variant = 0, unused_fields = 0): else: print "(var_ref P)", + if tex_inst not in ['txf_ms', 'txs']: + # Coordinate offset if variant & Offset: print "(var_ref offset)", else: print "0", - if tex_inst != "txf" and tex_inst != "txs": + if tex_inst not in ['txf', 'txf_ms', 'txs']: # Projective divisor if variant & Proj: print "(swiz " + "xyzw"[coord_dim + extra_dim-1] + " (var_ref P))", @@ -125,11 +135,13 @@ def generate_sigs(g, tex_inst, sampler_type, variant = 0, unused_fields = 0): # Bias/explicit LOD/gradient: if tex_inst == "txb": print "(var_ref bias)", - elif tex_inst == "txs" or tex_inst == "txf": - if "Rect" not in sampler_type and "Buffer" not in sampler_type: + elif tex_inst in ['txs', 'txf', 'txf_ms']: + if has_lod(sampler_type): print "(var_ref lod)", + elif tex_inst == 'txf_ms': + print "(var_ref sample)", else: - print "(constant int (0))" + print "(constant int (0))", elif tex_inst == "txl": print "(var_ref lod)", elif tex_inst == "txd": @@ -173,6 +185,8 @@ def generate_texture_functions(fs): generate_fiu_sigs("txs", "Buffer") generate_fiu_sigs("txs", "CubeArray") generate_sigs("", "txs", "CubeArrayShadow") + generate_fiu_sigs("txs", "2DMS") + generate_fiu_sigs("txs", "2DMSArray") end_function(fs, "textureSize") start_function("texture") @@ -283,6 +297,8 @@ def generate_texture_functions(fs): generate_fiu_sigs("txf", "1DArray") generate_fiu_sigs("txf", "2DArray") generate_fiu_sigs("txf", "Buffer") + generate_fiu_sigs("txf_ms", "2DMS") + generate_fiu_sigs("txf_ms", "2DMSArray") end_function(fs, "texelFetch") start_function("texelFetchOffset") |