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 <kenneth@whitecape.org>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
This commit is contained in:
Chad Versace 2013-11-06 19:40:25 -08:00
parent 8d1a8d65b5
commit 95ebabbc5f
4 changed files with 37 additions and 40 deletions

View file

@ -277,26 +277,6 @@ brw_init_driver_functions(struct brw_context *brw,
functions->GetSamplePosition = gen6_get_sample_position;
}
/**
* 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;

View file

@ -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;
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;
case 7:
/* Gen7 supports 4x and 8x multisampling. */
if (num_samples > 4)
return 8;
else if (num_samples > 0)
return 4;
else
return 0;
return 0;
default:
/* MSAA unsupported. */
return 0;
break;
}
return quantized_samples;
}

View file

@ -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)
{

View file

@ -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