int maxWindowRectangles() const { return fMaxWindowRectangles; }
- virtual bool isConfigTexturable(GrPixelConfig config) const = 0;
+ virtual bool isConfigTexturable(GrPixelConfig) const = 0;
virtual bool isConfigRenderable(GrPixelConfig config, bool withMSAA) const = 0;
virtual bool canConfigBeImageStorage(GrPixelConfig config) const = 0;
int left, int top, int width, int height,
GrPixelConfig config, const SkTArray<GrMipLevel>& texels) {
SkASSERT(surface);
+
for (int currentMipLevel = 0; currentMipLevel < texels.count(); currentMipLevel++) {
if (!texels[currentMipLevel].fPixels ) {
return false;
} else if (fUsesMixedSamples) {
fMSFBOType = kMixedSamples_MSFBOType;
} else if (ctxInfo.version() >= GR_GL_VER(3,0) ||
- ctxInfo.hasExtension("GL_CHROMIUM_framebuffer_multisample") ||
- ctxInfo.hasExtension("GL_ANGLE_framebuffer_multisample")) {
+ ctxInfo.hasExtension("GL_CHROMIUM_framebuffer_multisample")) {
fMSFBOType = kStandard_MSFBOType;
+ } else if (ctxInfo.hasExtension("GL_ANGLE_framebuffer_multisample")) {
+ fMSFBOType = kEXT_MSFBOType;
} else if (ctxInfo.hasExtension("GL_APPLE_framebuffer_multisample")) {
fMSFBOType = kES_Apple_MSFBOType;
}
fConfigTable[kSRGBA_8888_GrPixelConfig].fFlags |= ConfigInfo::kCanUseTexStorage_Flag;
}
fConfigTable[kSRGBA_8888_GrPixelConfig].fSwizzle = GrSwizzle::RGBA();
-
// sBGRA is not a "real" thing in OpenGL, but GPUs support it, and on platforms where
// kN32 == BGRA, we need some way to work with it. (The default framebuffer on Windows
// is in this format, for example).
GR_GL_BGRA;
fConfigTable[kSBGRA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED_BYTE;
fConfigTable[kSBGRA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_FormatType;
- if (fSRGBSupport) {
+ if (fSRGBSupport && kGL_GrGLStandard == standard) {
fConfigTable[kSBGRA_8888_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag |
allRenderFlags;
}
+
if (texStorageSupported) {
fConfigTable[kSBGRA_8888_GrPixelConfig].fFlags |= ConfigInfo::kCanUseTexStorage_Flag;
}
// [half] floating point textures became part of the standard in ES3.1 / OGL 3.0.
bool hasFPTextures = false;
bool hasHalfFPTextures = false;
+ bool rgIsTexturable = false;
// for now we don't support floating point MSAA on ES
uint32_t fpRenderFlags = (kGL_GrGLStandard == standard) ? allRenderFlags : nonMSAARenderFlags;
if (version >= GR_GL_VER(3, 0) || ctxInfo.hasExtension("GL_ARB_texture_float")) {
hasFPTextures = true;
hasHalfFPTextures = true;
+ rgIsTexturable = true;
}
} else {
if (version >= GR_GL_VER(3, 1)) {
hasFPTextures = true;
hasHalfFPTextures = true;
+ rgIsTexturable = true;
} else {
if (ctxInfo.hasExtension("GL_OES_texture_float_linear") &&
ctxInfo.hasExtension("GL_OES_texture_float")) {
fConfigTable[fpconfig].fFormats.fExternalType = GR_GL_FLOAT;
fConfigTable[fpconfig].fFormatType = kFloat_FormatType;
if (hasFPTextures) {
- fConfigTable[fpconfig].fFlags = ConfigInfo::kTextureable_Flag;
+ fConfigTable[fpconfig].fFlags = rgIsTexturable ? ConfigInfo::kTextureable_Flag : 0;
// For now we only enable rendering to float on desktop, because on ES we'd have to
// solve many precision issues and no clients actually want this yet.
if (kGL_GrGLStandard == standard /* || version >= GR_GL_VER(3,2) ||
if (SkToBool(VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT & vkFlags) &&
SkToBool(VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT & vkFlags)) {
*flags = *flags | kTextureable_Flag;
- }
- if (SkToBool(VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT & vkFlags)) {
- *flags = *flags | kRenderable_Flag;
+ // Ganesh assumes that all renderable surfaces are also texturable
+ if (SkToBool(VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT & vkFlags)) {
+ *flags = *flags | kRenderable_Flag;
+ }
}
if (SkToBool(VK_FORMAT_FEATURE_BLIT_SRC_BIT & vkFlags)) {
context->getGpu()->deleteTestingOnlyBackendTexture(backendTexHandle);
}
+#if 0
+// This test checks that the isConfigTexturable and isConfigRenderable are
+// consistent with createTexture's result.
+DEF_GPUTEST_FOR_ALL_CONTEXTS(GrSurfaceRenderability, reporter, ctxInfo) {
+ GrContext* context = ctxInfo.grContext();
+ const GrCaps* caps = context->caps();
+
+ GrPixelConfig configs[] = {
+ kUnknown_GrPixelConfig,
+ kAlpha_8_GrPixelConfig,
+ kGray_8_GrPixelConfig,
+ kRGB_565_GrPixelConfig,
+ kRGBA_4444_GrPixelConfig,
+ kRGBA_8888_GrPixelConfig,
+ kBGRA_8888_GrPixelConfig,
+ kSRGBA_8888_GrPixelConfig,
+ kSBGRA_8888_GrPixelConfig,
+ kRGBA_8888_sint_GrPixelConfig,
+ kETC1_GrPixelConfig,
+ kRGBA_float_GrPixelConfig,
+ kRG_float_GrPixelConfig,
+ kAlpha_half_GrPixelConfig,
+ kRGBA_half_GrPixelConfig,
+ };
+ SkASSERT(kGrPixelConfigCnt == SK_ARRAY_COUNT(configs));
+
+ GrSurfaceDesc desc;
+ desc.fWidth = 64;
+ desc.fHeight = 64;
+
+ for (GrPixelConfig config : configs) {
+ for (GrSurfaceOrigin origin : { kTopLeft_GrSurfaceOrigin, kBottomLeft_GrSurfaceOrigin }) {
+ desc.fFlags = kNone_GrSurfaceFlags;
+ desc.fOrigin = origin;
+ desc.fSampleCnt = 0;
+ desc.fConfig = config;
+
+ sk_sp<GrSurface> tex = context->resourceProvider()->createTexture(desc, SkBudgeted::kNo);
+ REPORTER_ASSERT(reporter, SkToBool(tex.get()) == caps->isConfigTexturable(desc.fConfig,
+ desc.fOrigin));
+
+ desc.fFlags = kRenderTarget_GrSurfaceFlag;
+ tex = context->resourceProvider()->createTexture(desc, SkBudgeted::kNo);
+ REPORTER_ASSERT(reporter, SkToBool(tex.get()) == caps->isConfigRenderable(config, false));
+
+ desc.fSampleCnt = 4;
+ tex = context->resourceProvider()->createTexture(desc, SkBudgeted::kNo);
+ REPORTER_ASSERT(reporter, SkToBool(tex.get()) == caps->isConfigRenderable(config, true));
+ }
+ }
+}
+#endif
+
#endif
static const size_t kRowBytes = kS * sizeof(int32_t);
GrSurfaceDesc desc;
+ desc.fOrigin = kTopLeft_GrSurfaceOrigin;
desc.fConfig = kRGBA_8888_sint_GrPixelConfig;
desc.fWidth = kS;
desc.fHeight = kS;
class MockCaps : public GrCaps {
public:
explicit MockCaps(const GrContextOptions& options) : INHERITED(options) {}
- bool isConfigTexturable(GrPixelConfig config) const override { return false; }
+ bool isConfigTexturable(GrPixelConfig) const override { return false; }
bool isConfigRenderable(GrPixelConfig config, bool withMSAA) const override { return false; }
bool canConfigBeImageStorage(GrPixelConfig) const override { return false; }
bool initDescForDstCopy(const GrRenderTargetProxy* src, GrSurfaceDesc* desc,