Rip out CSAA support
R=robertphillips@google.com Author: bsalomon@google.com Review URL: https://chromiumcodereview.appspot.com/23882009 git-svn-id: http://skia.googlecode.com/svn/trunk@11138 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
96a7a9623f
commit
040fd8f567
@ -129,7 +129,6 @@ extern "C" {
|
|||||||
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLReadPixelsProc)(GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height, GrGLenum format, GrGLenum type, GrGLvoid* pixels);
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLReadPixelsProc)(GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height, GrGLenum format, GrGLenum type, GrGLvoid* pixels);
|
||||||
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLRenderbufferStorageProc)(GrGLenum target, GrGLenum internalformat, GrGLsizei width, GrGLsizei height);
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLRenderbufferStorageProc)(GrGLenum target, GrGLenum internalformat, GrGLsizei width, GrGLsizei height);
|
||||||
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLRenderbufferStorageMultisampleProc)(GrGLenum target, GrGLsizei samples, GrGLenum internalformat, GrGLsizei width, GrGLsizei height);
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLRenderbufferStorageMultisampleProc)(GrGLenum target, GrGLsizei samples, GrGLenum internalformat, GrGLsizei width, GrGLsizei height);
|
||||||
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLRenderbufferStorageMultisampleCoverageProc)(GrGLenum target, GrGLsizei coverageSamples, GrGLsizei colorSamples, GrGLenum internalformat, GrGLsizei width, GrGLsizei height);
|
|
||||||
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLResolveMultisampleFramebufferProc)();
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLResolveMultisampleFramebufferProc)();
|
||||||
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLScissorProc)(GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height);
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLScissorProc)(GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height);
|
||||||
#if GR_GL_USE_NEW_SHADER_SOURCE_SIGNATURE
|
#if GR_GL_USE_NEW_SHADER_SOURCE_SIGNATURE
|
||||||
|
@ -254,7 +254,6 @@ public:
|
|||||||
// the standard function in ES3+ or GL 3.0+.
|
// the standard function in ES3+ or GL 3.0+.
|
||||||
GLPtr<GrGLRenderbufferStorageMultisampleProc> fRenderbufferStorageMultisample;
|
GLPtr<GrGLRenderbufferStorageMultisampleProc> fRenderbufferStorageMultisample;
|
||||||
|
|
||||||
GLPtr<GrGLRenderbufferStorageMultisampleCoverageProc> fRenderbufferStorageMultisampleCoverage;
|
|
||||||
GLPtr<GrGLResolveMultisampleFramebufferProc> fResolveMultisampleFramebuffer;
|
GLPtr<GrGLResolveMultisampleFramebufferProc> fResolveMultisampleFramebuffer;
|
||||||
GLPtr<GrGLScissorProc> fScissor;
|
GLPtr<GrGLScissorProc> fScissor;
|
||||||
GLPtr<GrGLShaderSourceProc> fShaderSource;
|
GLPtr<GrGLShaderSourceProc> fShaderSource;
|
||||||
|
@ -43,8 +43,6 @@
|
|||||||
#define SK_WGL_FULL_ACCELERATION 0x2027
|
#define SK_WGL_FULL_ACCELERATION 0x2027
|
||||||
#define SK_WGL_SAMPLE_BUFFERS 0x2041
|
#define SK_WGL_SAMPLE_BUFFERS 0x2041
|
||||||
#define SK_WGL_SAMPLES 0x2042
|
#define SK_WGL_SAMPLES 0x2042
|
||||||
#define SK_WGL_COVERAGE_SAMPLES 0x2042 /* same as SAMPLES */
|
|
||||||
#define SK_WGL_COLOR_SAMPLES 0x20B9
|
|
||||||
#define SK_WGL_CONTEXT_MAJOR_VERSION 0x2091
|
#define SK_WGL_CONTEXT_MAJOR_VERSION 0x2091
|
||||||
#define SK_WGL_CONTEXT_MINOR_VERSION 0x2092
|
#define SK_WGL_CONTEXT_MINOR_VERSION 0x2092
|
||||||
#define SK_WGL_CONTEXT_LAYER_PLANE 0x2093
|
#define SK_WGL_CONTEXT_LAYER_PLANE 0x2093
|
||||||
|
@ -24,7 +24,6 @@ void GrGLCaps::reset() {
|
|||||||
fStencilFormats.reset();
|
fStencilFormats.reset();
|
||||||
fStencilVerifiedColorConfigs.reset();
|
fStencilVerifiedColorConfigs.reset();
|
||||||
fMSFBOType = kNone_MSFBOType;
|
fMSFBOType = kNone_MSFBOType;
|
||||||
fCoverageAAType = kNone_CoverageAAType;
|
|
||||||
fFBFetchType = kNone_FBFetchType;
|
fFBFetchType = kNone_FBFetchType;
|
||||||
fMaxFragmentUniformVectors = 0;
|
fMaxFragmentUniformVectors = 0;
|
||||||
fMaxVertexAttributes = 0;
|
fMaxVertexAttributes = 0;
|
||||||
@ -65,8 +64,6 @@ GrGLCaps& GrGLCaps::operator = (const GrGLCaps& caps) {
|
|||||||
fMaxFragmentTextureUnits = caps.fMaxFragmentTextureUnits;
|
fMaxFragmentTextureUnits = caps.fMaxFragmentTextureUnits;
|
||||||
fMaxFixedFunctionTextureCoords = caps.fMaxFixedFunctionTextureCoords;
|
fMaxFixedFunctionTextureCoords = caps.fMaxFixedFunctionTextureCoords;
|
||||||
fMSFBOType = caps.fMSFBOType;
|
fMSFBOType = caps.fMSFBOType;
|
||||||
fCoverageAAType = caps.fCoverageAAType;
|
|
||||||
fMSAACoverageModes = caps.fMSAACoverageModes;
|
|
||||||
fFBFetchType = caps.fFBFetchType;
|
fFBFetchType = caps.fFBFetchType;
|
||||||
fRGBA8RenderbufferSupport = caps.fRGBA8RenderbufferSupport;
|
fRGBA8RenderbufferSupport = caps.fRGBA8RenderbufferSupport;
|
||||||
fBGRAFormatSupport = caps.fBGRAFormatSupport;
|
fBGRAFormatSupport = caps.fBGRAFormatSupport;
|
||||||
@ -368,20 +365,6 @@ bool GrGLCaps::readPixelsSupported(const GrGLInterface* intf,
|
|||||||
return (GrGLenum)otherFormat == format && (GrGLenum)otherType == type;
|
return (GrGLenum)otherFormat == format && (GrGLenum)otherType == type;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
|
||||||
bool cov_mode_less(const GrGLCaps::MSAACoverageMode& left,
|
|
||||||
const GrGLCaps::MSAACoverageMode& right) {
|
|
||||||
if (left.fCoverageSampleCnt < right.fCoverageSampleCnt) {
|
|
||||||
return true;
|
|
||||||
} else if (right.fCoverageSampleCnt < left.fCoverageSampleCnt) {
|
|
||||||
return false;
|
|
||||||
} else if (left.fColorSampleCnt < right.fColorSampleCnt) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void GrGLCaps::initFSAASupport(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) {
|
void GrGLCaps::initFSAASupport(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) {
|
||||||
|
|
||||||
fMSFBOType = kNone_MSFBOType;
|
fMSFBOType = kNone_MSFBOType;
|
||||||
@ -409,49 +392,6 @@ void GrGLCaps::initFSAASupport(const GrGLContextInfo& ctxInfo, const GrGLInterfa
|
|||||||
ctxInfo.hasExtension("GL_EXT_framebuffer_blit")) {
|
ctxInfo.hasExtension("GL_EXT_framebuffer_blit")) {
|
||||||
fMSFBOType = GrGLCaps::kDesktop_EXT_MSFBOType;
|
fMSFBOType = GrGLCaps::kDesktop_EXT_MSFBOType;
|
||||||
}
|
}
|
||||||
// TODO: We could populate fMSAACoverageModes using GetInternalformativ
|
|
||||||
// on GL 4.2+. It's format-specific, though. See also
|
|
||||||
// http://code.google.com/p/skia/issues/detail?id=470 about using actual
|
|
||||||
// rather than requested sample counts in cache key.
|
|
||||||
if (ctxInfo.hasExtension("GL_NV_framebuffer_multisample_coverage")) {
|
|
||||||
fCoverageAAType = kNVDesktop_CoverageAAType;
|
|
||||||
GrGLint count;
|
|
||||||
GR_GL_GetIntegerv(gli,
|
|
||||||
GR_GL_MAX_MULTISAMPLE_COVERAGE_MODES,
|
|
||||||
&count);
|
|
||||||
fMSAACoverageModes.setCount(count);
|
|
||||||
GR_GL_GetIntegerv(gli,
|
|
||||||
GR_GL_MULTISAMPLE_COVERAGE_MODES,
|
|
||||||
(int*)&fMSAACoverageModes[0]);
|
|
||||||
// The NV driver seems to return the modes already sorted but the
|
|
||||||
// spec doesn't require this. So we sort.
|
|
||||||
typedef SkTLessFunctionToFunctorAdaptor<MSAACoverageMode, cov_mode_less> SortFunctor;
|
|
||||||
SortFunctor sortFunctor;
|
|
||||||
SkTQSort<MSAACoverageMode, SortFunctor>(fMSAACoverageModes.begin(),
|
|
||||||
fMSAACoverageModes.end() - 1,
|
|
||||||
sortFunctor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const GrGLCaps::MSAACoverageMode& GrGLCaps::getMSAACoverageMode(int desiredSampleCount) const {
|
|
||||||
static const MSAACoverageMode kNoneMode = {0, 0};
|
|
||||||
if (0 == fMSAACoverageModes.count()) {
|
|
||||||
return kNoneMode;
|
|
||||||
} else {
|
|
||||||
SkASSERT(kNone_CoverageAAType != fCoverageAAType);
|
|
||||||
int max = (fMSAACoverageModes.end() - 1)->fCoverageSampleCnt;
|
|
||||||
desiredSampleCount = GrMin(desiredSampleCount, max);
|
|
||||||
MSAACoverageMode desiredMode = {desiredSampleCount, 0};
|
|
||||||
int idx = SkTSearch<const MSAACoverageMode, cov_mode_less>(&fMSAACoverageModes[0],
|
|
||||||
fMSAACoverageModes.count(),
|
|
||||||
desiredMode,
|
|
||||||
sizeof(MSAACoverageMode));
|
|
||||||
if (idx < 0) {
|
|
||||||
idx = ~idx;
|
|
||||||
}
|
|
||||||
SkASSERT(idx >= 0 && idx < fMSAACoverageModes.count());
|
|
||||||
return fMSAACoverageModes[idx];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,23 +27,6 @@ public:
|
|||||||
|
|
||||||
typedef GrGLStencilBuffer::Format StencilFormat;
|
typedef GrGLStencilBuffer::Format StencilFormat;
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents a supported multisampling/coverage-sampling mode.
|
|
||||||
*/
|
|
||||||
struct MSAACoverageMode {
|
|
||||||
// "Coverage samples" includes samples that actually have color, depth,
|
|
||||||
// stencil, ... as well as those that don't (coverage only). All samples
|
|
||||||
// are coverage samples. (We're using the word "coverage sample" to
|
|
||||||
// match the NV extension language.)
|
|
||||||
int fCoverageSampleCnt;
|
|
||||||
|
|
||||||
// Color samples are samples that store data values (color, stencil,
|
|
||||||
// depth) rather than just representing coverage. They are a subset
|
|
||||||
// of coverage samples. (Again the wording was chosen to match the
|
|
||||||
// extension.)
|
|
||||||
int fColorSampleCnt;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type of MSAA for FBOs supported. Different extensions have different
|
* The type of MSAA for FBOs supported. Different extensions have different
|
||||||
* semantics of how / when a resolve is performed.
|
* semantics of how / when a resolve is performed.
|
||||||
@ -95,18 +78,6 @@ public:
|
|||||||
kLast_FBFetchType = kNV_FBFetchType,
|
kLast_FBFetchType = kNV_FBFetchType,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum CoverageAAType {
|
|
||||||
/**
|
|
||||||
* No coverage sample support
|
|
||||||
*/
|
|
||||||
kNone_CoverageAAType,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GL_NV_framebuffer_multisample_coverage
|
|
||||||
*/
|
|
||||||
kNVDesktop_CoverageAAType,
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a GrGLCaps that advertises no support for any extensions,
|
* Creates a GrGLCaps that advertises no support for any extensions,
|
||||||
* formats, etc. Call init to initialize from a GrGLContextInfo.
|
* formats, etc. Call init to initialize from a GrGLContextInfo.
|
||||||
@ -186,20 +157,6 @@ public:
|
|||||||
kES_EXT_MsToTexture_MSFBOType == fMSFBOType;
|
kES_EXT_MsToTexture_MSFBOType == fMSFBOType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Reports the type of coverage sample AA support.
|
|
||||||
*/
|
|
||||||
CoverageAAType coverageAAType() const { return fCoverageAAType; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Chooses a supported coverage mode based on a desired sample count. The
|
|
||||||
* desired sample count is rounded up the next supported coverage sample
|
|
||||||
* count unless a it is larger than the max in which case it is rounded
|
|
||||||
* down. Once a coverage sample count is decided, the supported mode with
|
|
||||||
* the fewest color samples is chosen.
|
|
||||||
*/
|
|
||||||
const MSAACoverageMode& getMSAACoverageMode(int desiredSampleCount) const;
|
|
||||||
|
|
||||||
FBFetchType fbFetchType() const { return fFBFetchType; }
|
FBFetchType fbFetchType() const { return fFBFetchType; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -348,8 +305,6 @@ private:
|
|||||||
int fMaxFixedFunctionTextureCoords;
|
int fMaxFixedFunctionTextureCoords;
|
||||||
|
|
||||||
MSFBOType fMSFBOType;
|
MSFBOType fMSFBOType;
|
||||||
CoverageAAType fCoverageAAType;
|
|
||||||
SkTDArray<MSAACoverageMode> fMSAACoverageModes;
|
|
||||||
|
|
||||||
FBFetchType fFBFetchType;
|
FBFetchType fFBFetchType;
|
||||||
|
|
||||||
|
@ -768,27 +768,12 @@ bool GrGpuGL::uploadTexData(const GrGLTexture::Desc& desc,
|
|||||||
return succeeded;
|
return succeeded;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
static bool renderbuffer_storage_msaa(GrGLContext& ctx,
|
||||||
bool renderbuffer_storage_msaa(GrGLContext& ctx,
|
int sampleCount,
|
||||||
int sampleCount,
|
GrGLenum format,
|
||||||
GrGLenum format,
|
int width, int height) {
|
||||||
int width, int height) {
|
|
||||||
CLEAR_ERROR_BEFORE_ALLOC(ctx.interface());
|
CLEAR_ERROR_BEFORE_ALLOC(ctx.interface());
|
||||||
SkASSERT(GrGLCaps::kNone_MSFBOType != ctx.info().caps()->msFBOType());
|
SkASSERT(GrGLCaps::kNone_MSFBOType != ctx.info().caps()->msFBOType());
|
||||||
bool created = false;
|
|
||||||
if (GrGLCaps::kNVDesktop_CoverageAAType ==
|
|
||||||
ctx.info().caps()->coverageAAType()) {
|
|
||||||
const GrGLCaps::MSAACoverageMode& mode =
|
|
||||||
ctx.info().caps()->getMSAACoverageMode(sampleCount);
|
|
||||||
GL_ALLOC_CALL(ctx.interface(),
|
|
||||||
RenderbufferStorageMultisampleCoverage(GR_GL_RENDERBUFFER,
|
|
||||||
mode.fCoverageSampleCnt,
|
|
||||||
mode.fColorSampleCnt,
|
|
||||||
format,
|
|
||||||
width, height));
|
|
||||||
created = (GR_GL_NO_ERROR == CHECK_ALLOC_ERROR(ctx.interface()));
|
|
||||||
}
|
|
||||||
if (!created) {
|
|
||||||
#if GR_GL_IGNORE_ES3_MSAA
|
#if GR_GL_IGNORE_ES3_MSAA
|
||||||
GL_ALLOC_CALL(ctx.interface(),
|
GL_ALLOC_CALL(ctx.interface(),
|
||||||
RenderbufferStorageMultisample(GR_GL_RENDERBUFFER,
|
RenderbufferStorageMultisample(GR_GL_RENDERBUFFER,
|
||||||
@ -796,40 +781,37 @@ bool renderbuffer_storage_msaa(GrGLContext& ctx,
|
|||||||
format,
|
format,
|
||||||
width, height));
|
width, height));
|
||||||
#else
|
#else
|
||||||
switch (ctx.info().caps()->msFBOType()) {
|
switch (ctx.info().caps()->msFBOType()) {
|
||||||
case GrGLCaps::kDesktop_ARB_MSFBOType:
|
case GrGLCaps::kDesktop_ARB_MSFBOType:
|
||||||
case GrGLCaps::kDesktop_EXT_MSFBOType:
|
case GrGLCaps::kDesktop_EXT_MSFBOType:
|
||||||
case GrGLCaps::kES_3_0_MSFBOType:
|
case GrGLCaps::kES_3_0_MSFBOType:
|
||||||
GL_ALLOC_CALL(ctx.interface(),
|
GL_ALLOC_CALL(ctx.interface(),
|
||||||
RenderbufferStorageMultisample(GR_GL_RENDERBUFFER,
|
RenderbufferStorageMultisample(GR_GL_RENDERBUFFER,
|
||||||
sampleCount,
|
sampleCount,
|
||||||
format,
|
format,
|
||||||
width, height));
|
width, height));
|
||||||
break;
|
break;
|
||||||
case GrGLCaps::kES_Apple_MSFBOType:
|
case GrGLCaps::kES_Apple_MSFBOType:
|
||||||
GL_ALLOC_CALL(ctx.interface(),
|
GL_ALLOC_CALL(ctx.interface(),
|
||||||
RenderbufferStorageMultisampleES2APPLE(GR_GL_RENDERBUFFER,
|
RenderbufferStorageMultisampleES2APPLE(GR_GL_RENDERBUFFER,
|
||||||
sampleCount,
|
sampleCount,
|
||||||
format,
|
format,
|
||||||
width, height));
|
width, height));
|
||||||
break;
|
break;
|
||||||
case GrGLCaps::kES_EXT_MsToTexture_MSFBOType:
|
case GrGLCaps::kES_EXT_MsToTexture_MSFBOType:
|
||||||
case GrGLCaps::kES_IMG_MsToTexture_MSFBOType:
|
case GrGLCaps::kES_IMG_MsToTexture_MSFBOType:
|
||||||
GL_ALLOC_CALL(ctx.interface(),
|
GL_ALLOC_CALL(ctx.interface(),
|
||||||
RenderbufferStorageMultisampleES2EXT(GR_GL_RENDERBUFFER,
|
RenderbufferStorageMultisampleES2EXT(GR_GL_RENDERBUFFER,
|
||||||
sampleCount,
|
sampleCount,
|
||||||
format,
|
format,
|
||||||
width, height));
|
width, height));
|
||||||
break;
|
break;
|
||||||
case GrGLCaps::kNone_MSFBOType:
|
case GrGLCaps::kNone_MSFBOType:
|
||||||
GrCrash("Shouldn't be here if we don't support multisampled renderbuffers.");
|
GrCrash("Shouldn't be here if we don't support multisampled renderbuffers.");
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
#endif
|
|
||||||
created = (GR_GL_NO_ERROR == CHECK_ALLOC_ERROR(ctx.interface()));
|
|
||||||
}
|
}
|
||||||
return created;
|
#endif
|
||||||
}
|
return (GR_GL_NO_ERROR == CHECK_ALLOC_ERROR(ctx.interface()));;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GrGpuGL::createRenderTargetObjects(int width, int height,
|
bool GrGpuGL::createRenderTargetObjects(int width, int height,
|
||||||
|
@ -123,9 +123,6 @@ const GrGLInterface* GrGLCreateNativeInterface() {
|
|||||||
interface->fPixelStorei = glPixelStorei;
|
interface->fPixelStorei = glPixelStorei;
|
||||||
interface->fReadBuffer = glReadBuffer;
|
interface->fReadBuffer = glReadBuffer;
|
||||||
interface->fReadPixels = glReadPixels;
|
interface->fReadPixels = glReadPixels;
|
||||||
if (extensions.has("GL_NV_framebuffer_multisample_coverage")) {
|
|
||||||
GR_GL_GET_PROC_SUFFIX(RenderbufferStorageMultisampleCoverage, NV);
|
|
||||||
}
|
|
||||||
interface->fScissor = glScissor;
|
interface->fScissor = glScissor;
|
||||||
GR_GL_GET_PROC(ShaderSource);
|
GR_GL_GET_PROC(ShaderSource);
|
||||||
interface->fStencilFunc = glStencilFunc;
|
interface->fStencilFunc = glStencilFunc;
|
||||||
|
@ -180,9 +180,6 @@ const GrGLInterface* GrGLCreateNativeInterface() {
|
|||||||
WGL_SET_PROC(GetStringi)
|
WGL_SET_PROC(GetStringi)
|
||||||
WGL_SET_PROC(GetUniformLocation);
|
WGL_SET_PROC(GetUniformLocation);
|
||||||
WGL_SET_PROC(LinkProgram);
|
WGL_SET_PROC(LinkProgram);
|
||||||
if (extensions.has("GL_NV_framebuffer_multisample_coverage")) {
|
|
||||||
WGL_SET_PROC_SUFFIX(RenderbufferStorageMultisampleCoverage, NV);
|
|
||||||
}
|
|
||||||
WGL_SET_PROC(ShaderSource);
|
WGL_SET_PROC(ShaderSource);
|
||||||
WGL_SET_PROC(StencilFuncSeparate);
|
WGL_SET_PROC(StencilFuncSeparate);
|
||||||
WGL_SET_PROC(StencilMaskSeparate);
|
WGL_SET_PROC(StencilMaskSeparate);
|
||||||
|
@ -79,19 +79,14 @@ namespace {
|
|||||||
|
|
||||||
struct PixelFormat {
|
struct PixelFormat {
|
||||||
int fFormat;
|
int fFormat;
|
||||||
int fCoverageSamples;
|
int fSampleCnt;
|
||||||
int fColorSamples;
|
|
||||||
int fChoosePixelFormatRank;
|
int fChoosePixelFormatRank;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool pf_less(const PixelFormat& a, const PixelFormat& b) {
|
bool pf_less(const PixelFormat& a, const PixelFormat& b) {
|
||||||
if (a.fCoverageSamples < b.fCoverageSamples) {
|
if (a.fSampleCnt < b.fSampleCnt) {
|
||||||
return true;
|
return true;
|
||||||
} else if (b.fCoverageSamples < a.fCoverageSamples) {
|
} else if (b.fSampleCnt < a.fSampleCnt) {
|
||||||
return false;
|
|
||||||
} else if (a.fColorSamples < b.fColorSamples) {
|
|
||||||
return true;
|
|
||||||
} else if (b.fColorSamples < a.fColorSamples) {
|
|
||||||
return false;
|
return false;
|
||||||
} else if (a.fChoosePixelFormatRank < b.fChoosePixelFormatRank) {
|
} else if (a.fChoosePixelFormatRank < b.fChoosePixelFormatRank) {
|
||||||
return true;
|
return true;
|
||||||
@ -108,31 +103,20 @@ int SkWGLExtensions::selectFormat(const int formats[],
|
|||||||
0,
|
0,
|
||||||
desiredSampleCount,
|
desiredSampleCount,
|
||||||
0,
|
0,
|
||||||
0,
|
|
||||||
};
|
};
|
||||||
SkTDArray<PixelFormat> rankedFormats;
|
SkTDArray<PixelFormat> rankedFormats;
|
||||||
rankedFormats.setCount(formatCount);
|
rankedFormats.setCount(formatCount);
|
||||||
bool supportsCoverage = this->hasExtension(dc,
|
|
||||||
"WGL_NV_multisample_coverage");
|
|
||||||
for (int i = 0; i < formatCount; ++i) {
|
for (int i = 0; i < formatCount; ++i) {
|
||||||
static const int queryAttrs[] = {
|
static const int kQueryAttr = SK_WGL_SAMPLES;
|
||||||
SK_WGL_COVERAGE_SAMPLES,
|
int numSamples;
|
||||||
// Keep COLOR_SAMPLES at the end so it can be skipped
|
|
||||||
SK_WGL_COLOR_SAMPLES,
|
|
||||||
};
|
|
||||||
int answers[2];
|
|
||||||
int queryAttrCnt = supportsCoverage ?
|
|
||||||
SK_ARRAY_COUNT(queryAttrs) :
|
|
||||||
SK_ARRAY_COUNT(queryAttrs) - 1;
|
|
||||||
this->getPixelFormatAttribiv(dc,
|
this->getPixelFormatAttribiv(dc,
|
||||||
formats[i],
|
formats[i],
|
||||||
0,
|
0,
|
||||||
queryAttrCnt,
|
1,
|
||||||
queryAttrs,
|
&kQueryAttr,
|
||||||
answers);
|
&numSamples);
|
||||||
rankedFormats[i].fFormat = formats[i];
|
rankedFormats[i].fFormat = formats[i];
|
||||||
rankedFormats[i].fCoverageSamples = answers[0];
|
rankedFormats[i].fSampleCnt = numSamples;
|
||||||
rankedFormats[i].fColorSamples = answers[supportsCoverage ? 1 : 0];
|
|
||||||
rankedFormats[i].fChoosePixelFormatRank = i;
|
rankedFormats[i].fChoosePixelFormatRank = i;
|
||||||
}
|
}
|
||||||
SkTQSort(rankedFormats.begin(),
|
SkTQSort(rankedFormats.begin(),
|
||||||
@ -289,7 +273,7 @@ HGLRC SkCreateWGLContext(HDC dc, int msaaSampleCount, bool preferCoreProfile) {
|
|||||||
if (msaaSampleCount > 0 &&
|
if (msaaSampleCount > 0 &&
|
||||||
extensions.hasExtension(dc, "WGL_ARB_multisample")) {
|
extensions.hasExtension(dc, "WGL_ARB_multisample")) {
|
||||||
static const int kIAttrsCount = SK_ARRAY_COUNT(iAttrs);
|
static const int kIAttrsCount = SK_ARRAY_COUNT(iAttrs);
|
||||||
int msaaIAttrs[kIAttrsCount + 6];
|
int msaaIAttrs[kIAttrsCount + 4];
|
||||||
memcpy(msaaIAttrs, iAttrs, sizeof(int) * kIAttrsCount);
|
memcpy(msaaIAttrs, iAttrs, sizeof(int) * kIAttrsCount);
|
||||||
SkASSERT(0 == msaaIAttrs[kIAttrsCount - 2] &&
|
SkASSERT(0 == msaaIAttrs[kIAttrsCount - 2] &&
|
||||||
0 == msaaIAttrs[kIAttrsCount - 1]);
|
0 == msaaIAttrs[kIAttrsCount - 1]);
|
||||||
@ -297,18 +281,8 @@ HGLRC SkCreateWGLContext(HDC dc, int msaaSampleCount, bool preferCoreProfile) {
|
|||||||
msaaIAttrs[kIAttrsCount - 1] = TRUE;
|
msaaIAttrs[kIAttrsCount - 1] = TRUE;
|
||||||
msaaIAttrs[kIAttrsCount + 0] = SK_WGL_SAMPLES;
|
msaaIAttrs[kIAttrsCount + 0] = SK_WGL_SAMPLES;
|
||||||
msaaIAttrs[kIAttrsCount + 1] = msaaSampleCount;
|
msaaIAttrs[kIAttrsCount + 1] = msaaSampleCount;
|
||||||
if (extensions.hasExtension(dc, "WGL_NV_multisample_coverage")) {
|
msaaIAttrs[kIAttrsCount + 2] = 0;
|
||||||
msaaIAttrs[kIAttrsCount + 2] = SK_WGL_COLOR_SAMPLES;
|
msaaIAttrs[kIAttrsCount + 3] = 0;
|
||||||
// We want the fewest number of color samples possible.
|
|
||||||
// Passing 0 gives only the formats where all samples are color
|
|
||||||
// samples.
|
|
||||||
msaaIAttrs[kIAttrsCount + 3] = 1;
|
|
||||||
msaaIAttrs[kIAttrsCount + 4] = 0;
|
|
||||||
msaaIAttrs[kIAttrsCount + 5] = 0;
|
|
||||||
} else {
|
|
||||||
msaaIAttrs[kIAttrsCount + 2] = 0;
|
|
||||||
msaaIAttrs[kIAttrsCount + 3] = 0;
|
|
||||||
}
|
|
||||||
unsigned int num;
|
unsigned int num;
|
||||||
int formats[64];
|
int formats[64];
|
||||||
extensions.choosePixelFormat(dc, msaaIAttrs, fAttrs, 64, formats, &num);
|
extensions.choosePixelFormat(dc, msaaIAttrs, fAttrs, 64, formats, &num);
|
||||||
|
Loading…
Reference in New Issue
Block a user