diff options
author | Marek Olšák <[email protected]> | 2014-01-08 01:09:15 +0100 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2014-01-13 15:48:07 +0100 |
commit | 9baa45f78b8ca7d66280e36009b6a685055d7cd6 (patch) | |
tree | 1aa17409335d9643983dfcd7abbbcc0126581817 /src/gallium/auxiliary/util/u_framebuffer.c | |
parent | 9bf9578c1b79e5622a2325f1a2bb80fcf0e22a6d (diff) |
st/mesa: bind NULL colorbuffers as specified by glDrawBuffers
An example why it is required:
Let's say there's a fragment shader writing to gl_FragData[0..1].
The user calls: glDrawBuffers(2, {GL_NONE, GL_COLOR_ATTACHMENT0});
That means gl_FragData[0] is unused and gl_FragData[1] is written
to GL_COLOR_ATTACHMENT0.
st/mesa was skipping the GL_NONE draw buffer, therefore gl_FragData[0]
was written to GL_COLOR_ATTACHMENT0, which was wrong.
This commit fixes it, but drivers must also be fixed not to crash when
binding NULL colorbuffers. There is also a new set of piglit tests for this.
The MSAA state also had to be fixed not to crash when reading fb->cbufs[0].
Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary/util/u_framebuffer.c')
-rw-r--r-- | src/gallium/auxiliary/util/u_framebuffer.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/util/u_framebuffer.c b/src/gallium/auxiliary/util/u_framebuffer.c index 683967237e9..377b802b62a 100644 --- a/src/gallium/auxiliary/util/u_framebuffer.c +++ b/src/gallium/auxiliary/util/u_framebuffer.c @@ -171,3 +171,24 @@ util_framebuffer_get_num_layers(const struct pipe_framebuffer_state *fb) } return num_layers; } + + +/** + * Return the number of MSAA samples. + */ +unsigned +util_framebuffer_get_num_samples(const struct pipe_framebuffer_state *fb) +{ + unsigned i; + + for (i = 0; i < fb->nr_cbufs; i++) { + if (fb->cbufs[i]) { + return MAX2(1, fb->cbufs[i]->texture->nr_samples); + } + } + if (fb->zsbuf) { + return MAX2(1, fb->zsbuf->texture->nr_samples); + } + + return 1; +} |