diff options
author | Chad Versace <[email protected]> | 2013-11-06 19:40:25 -0800 |
---|---|---|
committer | Chad Versace <[email protected]> | 2013-11-22 14:56:15 -0800 |
commit | 95ebabbc5fceec6a9c37dbb4d8f3282a86fe02ce (patch) | |
tree | 7ddb66d3d69a62847d722f5441998a1df85d2b5d /src/mesa/drivers | |
parent | 8d1a8d65b55bac28fe2c63847b1ef216b7f2c9aa (diff) |
i965: Share code between intel_quantize_num_samples and clamp_max_samples
clamp_max_samples() and intel_quantize_num_samples() each maintained
their own list of which MSAA modes the hardware supports. This patch
removes the duplication by making intel_quantize_num_samples() use the
same list as clamp_max_samples(), the list maintained in
brw_supported_msaa_modes().
By removing the duplication, we prevent the scenario where someone
updates one list but forgets to update the other.
Move function `brw_context.c:static brw_supported_msaa_modes()` to
`intel_screen.c:(non-static) intel_supported_msaa_modes()` and patch
intel_quantize_num_samples() to use the list returned by that function.
Reviewed-by: Kenneth Graunke <[email protected]>
Signed-off-by: Chad Versace <[email protected]>
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_context.c | 26 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/intel_fbo.c | 28 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/intel_screen.c | 20 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/intel_screen.h | 3 |
4 files changed, 37 insertions, 40 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index 52b1084322d..125bc557b55 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -278,26 +278,6 @@ brw_init_driver_functions(struct brw_context *brw, } /** - * Return array of MSAA modes supported by the hardware. The array is - * terminated by -1 and sorted in decreasing order. - */ -static const int* -brw_supported_msaa_modes(const struct brw_context *brw) -{ - static const int gen7_samples[] = {8, 4, 0, -1}; - static const int gen6_samples[] = {4, 0, -1}; - static const int gen4_samples[] = {0, -1}; - - if (brw->gen >= 7) { - return gen7_samples; - } else if (brw->gen == 6) { - return gen6_samples; - } else { - return gen4_samples; - } -} - -/** * Override GL_MAX_SAMPLES and related constants according to value of driconf * option 'clamp_max_samples'. */ @@ -309,7 +289,8 @@ brw_override_max_samples(struct brw_context *brw) if (clamp_max_samples < 0) return; - const int *supported_msaa_modes = brw_supported_msaa_modes(brw); + const int *supported_msaa_modes = + intel_supported_msaa_modes(brw->intelScreen); int max_samples = 0; /* Select the largest supported MSAA mode that does not exceed @@ -393,7 +374,8 @@ brw_initialize_context_constants(struct brw_context *brw) ctx->Const.AlwaysUseGetTransformFeedbackVertexCount = true; - const int max_samples = brw_supported_msaa_modes(brw)[0]; + const int max_samples = + intel_supported_msaa_modes(brw->intelScreen)[0]; ctx->Const.MaxSamples = max_samples; ctx->Const.MaxColorTextureSamples = max_samples; ctx->Const.MaxDepthTextureSamples = max_samples; diff --git a/src/mesa/drivers/dri/i965/intel_fbo.c b/src/mesa/drivers/dri/i965/intel_fbo.c index ddecb2b9800..472d2ca6f86 100644 --- a/src/mesa/drivers/dri/i965/intel_fbo.c +++ b/src/mesa/drivers/dri/i965/intel_fbo.c @@ -46,6 +46,7 @@ #include "intel_fbo.h" #include "intel_mipmap_tree.h" #include "intel_regions.h" +#include "intel_screen.h" #include "intel_tex.h" #include "brw_context.h" @@ -159,26 +160,17 @@ intel_unmap_renderbuffer(struct gl_context *ctx, unsigned intel_quantize_num_samples(struct intel_screen *intel, unsigned num_samples) { - switch (intel->devinfo->gen) { - case 6: - /* Gen6 supports only 4x multisampling. */ - if (num_samples > 0) - return 4; - else - return 0; - case 7: - /* Gen7 supports 4x and 8x multisampling. */ - if (num_samples > 4) - return 8; - else if (num_samples > 0) - return 4; + const int *msaa_modes = intel_supported_msaa_modes(intel); + int quantized_samples = 0; + + for (int i = 0; msaa_modes[i] != -1; ++i) { + if (msaa_modes[i] >= num_samples) + quantized_samples = msaa_modes[i]; else - return 0; - return 0; - default: - /* MSAA unsupported. */ - return 0; + break; } + + return quantized_samples; } diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c index fcf07e414ff..81901cc5a0a 100644 --- a/src/mesa/drivers/dri/i965/intel_screen.c +++ b/src/mesa/drivers/dri/i965/intel_screen.c @@ -1092,6 +1092,26 @@ intel_detect_swizzling(struct intel_screen *screen) return true; } +/** + * Return array of MSAA modes supported by the hardware. The array is + * zero-terminated and sorted in decreasing order. + */ +const int* +intel_supported_msaa_modes(const struct intel_screen *screen) +{ + static const int gen7_modes[] = {8, 4, 0, -1}; + static const int gen6_modes[] = {4, 0, -1}; + static const int gen4_modes[] = {0, -1}; + + if (screen->devinfo->gen >= 7) { + return gen7_modes; + } else if (screen->devinfo->gen == 6) { + return gen6_modes; + } else { + return gen4_modes; + } +} + static __DRIconfig** intel_screen_make_configs(__DRIscreen *dri_screen) { diff --git a/src/mesa/drivers/dri/i965/intel_screen.h b/src/mesa/drivers/dri/i965/intel_screen.h index eb9bfca1482..2e3043e27bf 100644 --- a/src/mesa/drivers/dri/i965/intel_screen.h +++ b/src/mesa/drivers/dri/i965/intel_screen.h @@ -77,4 +77,7 @@ intelMakeCurrent(__DRIcontext * driContextPriv, double get_time(void); void aub_dump_bmp(struct gl_context *ctx); +const int* +intel_supported_msaa_modes(const struct intel_screen *screen); + #endif |