mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1339256 - Detect robust_buffer_access_behavior. - r=daoshengmu
MozReview-Commit-ID: 4w5D9bOQbY8
This commit is contained in:
parent
554a65e406
commit
e63fc0df83
@ -1965,6 +1965,8 @@ protected:
|
||||
bool mNeedsFakeNoStencil;
|
||||
bool mNeedsEmulatedLoneDepthStencil;
|
||||
|
||||
bool mNeedsIndexValidation;
|
||||
|
||||
const bool mAllowFBInvalidation;
|
||||
|
||||
bool Has64BitTimestamps() const;
|
||||
|
@ -725,6 +725,11 @@ WebGLContext::InitAndValidateGL(FailureReason* const out_failReason)
|
||||
|
||||
mFakeVertexAttrib0BufferObject = 0;
|
||||
|
||||
mNeedsIndexValidation = !gl->IsSupported(gl::GLFeature::robust_buffer_access_behavior);
|
||||
if (gfxPrefs::WebGLForceIndexValidation()) {
|
||||
mNeedsIndexValidation = true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -103,6 +103,7 @@ static const char* const sExtensionNames[] = {
|
||||
"GL_ARB_map_buffer_range",
|
||||
"GL_ARB_occlusion_query2",
|
||||
"GL_ARB_pixel_buffer_object",
|
||||
"GL_ARB_robust_buffer_access_behavior",
|
||||
"GL_ARB_robustness",
|
||||
"GL_ARB_sampler_objects",
|
||||
"GL_ARB_seamless_cube_map",
|
||||
@ -157,6 +158,8 @@ static const char* const sExtensionNames[] = {
|
||||
"GL_IMG_texture_compression_pvrtc",
|
||||
"GL_IMG_texture_npot",
|
||||
"GL_KHR_debug",
|
||||
"GL_KHR_robust_buffer_access_behavior",
|
||||
"GL_KHR_robustness",
|
||||
"GL_KHR_texture_compression_astc_hdr",
|
||||
"GL_KHR_texture_compression_astc_ldr",
|
||||
"GL_NV_draw_instanced",
|
||||
@ -1143,31 +1146,15 @@ GLContext::LoadMoreSymbols(const char* prefix, bool trygl)
|
||||
};
|
||||
|
||||
if (IsSupported(GLFeature::robustness)) {
|
||||
bool hasRobustness = false;
|
||||
|
||||
if (!hasRobustness && IsExtensionSupported(ARB_robustness)) {
|
||||
const SymLoadStruct symbols[] = {
|
||||
{ (PRFuncPtr*) &mSymbols.fGetGraphicsResetStatus, { "GetGraphicsResetStatusARB", nullptr } },
|
||||
END_SYMBOLS
|
||||
};
|
||||
if (fnLoadForExt(symbols, ARB_robustness)) {
|
||||
hasRobustness = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasRobustness && IsExtensionSupported(EXT_robustness)) {
|
||||
const SymLoadStruct symbols[] = {
|
||||
{ (PRFuncPtr*) &mSymbols.fGetGraphicsResetStatus, { "GetGraphicsResetStatusEXT", nullptr } },
|
||||
END_SYMBOLS
|
||||
};
|
||||
if (fnLoadForExt(symbols, EXT_robustness)) {
|
||||
hasRobustness = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasRobustness) {
|
||||
MarkUnsupported(GLFeature::robustness);
|
||||
}
|
||||
const SymLoadStruct symbols[] = {
|
||||
{ (PRFuncPtr*) &mSymbols.fGetGraphicsResetStatus, { "GetGraphicsResetStatus",
|
||||
"GetGraphicsResetStatusARB",
|
||||
"GetGraphicsResetStatusKHR",
|
||||
"GetGraphicsResetStatusEXT",
|
||||
nullptr } },
|
||||
END_SYMBOLS
|
||||
};
|
||||
fnLoadForFeature(symbols, GLFeature::sync);
|
||||
}
|
||||
|
||||
if (IsSupported(GLFeature::sync)) {
|
||||
|
@ -121,6 +121,7 @@ enum class GLFeature {
|
||||
read_buffer,
|
||||
renderbuffer_color_float,
|
||||
renderbuffer_color_half_float,
|
||||
robust_buffer_access_behavior,
|
||||
robustness,
|
||||
sRGB_framebuffer,
|
||||
sRGB_texture,
|
||||
@ -199,10 +200,6 @@ class GLContext
|
||||
public:
|
||||
MOZ_DECLARE_WEAKREFERENCE_TYPENAME(GLContext)
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// basic enums
|
||||
public:
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// basic getters
|
||||
public:
|
||||
@ -434,6 +431,7 @@ public:
|
||||
ARB_map_buffer_range,
|
||||
ARB_occlusion_query2,
|
||||
ARB_pixel_buffer_object,
|
||||
ARB_robust_buffer_access_behavior,
|
||||
ARB_robustness,
|
||||
ARB_sampler_objects,
|
||||
ARB_seamless_cube_map,
|
||||
@ -488,6 +486,8 @@ public:
|
||||
IMG_texture_compression_pvrtc,
|
||||
IMG_texture_npot,
|
||||
KHR_debug,
|
||||
KHR_robust_buffer_access_behavior,
|
||||
KHR_robustness,
|
||||
KHR_texture_compression_astc_hdr,
|
||||
KHR_texture_compression_astc_ldr,
|
||||
NV_draw_instanced,
|
||||
@ -571,15 +571,6 @@ private:
|
||||
*/
|
||||
bool IsFeatureProvidedByCoreSymbols(GLFeature feature);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Robustness handling
|
||||
private:
|
||||
/**
|
||||
* The derived class is expected to provide information on whether or not it
|
||||
* supports robustness.
|
||||
*/
|
||||
virtual bool SupportsRobustness() const = 0;
|
||||
|
||||
public:
|
||||
// -----------------------------------------------------------------------------
|
||||
// Error handling
|
||||
|
@ -55,8 +55,6 @@ public:
|
||||
|
||||
virtual bool IsDoubleBuffered() const override;
|
||||
|
||||
virtual bool SupportsRobustness() const override { return false; }
|
||||
|
||||
virtual bool SwapBuffers() override;
|
||||
|
||||
virtual void GetWSIInfo(nsCString* const out) const override;
|
||||
|
@ -51,8 +51,6 @@ public:
|
||||
|
||||
virtual bool IsDoubleBuffered() const override;
|
||||
|
||||
virtual bool SupportsRobustness() const override { return false; }
|
||||
|
||||
virtual bool SwapBuffers() override;
|
||||
|
||||
virtual void GetWSIInfo(nsCString* const out) const override;
|
||||
|
@ -58,10 +58,6 @@ public:
|
||||
mIsDoubleBuffered = aIsDB;
|
||||
}
|
||||
|
||||
virtual bool SupportsRobustness() const override {
|
||||
return sEGLLibrary.HasRobustness();
|
||||
}
|
||||
|
||||
virtual bool IsANGLE() const override {
|
||||
return sEGLLibrary.IsANGLE();
|
||||
}
|
||||
|
@ -532,6 +532,17 @@ static const FeatureInfo sFeatureInfoArr[] = {
|
||||
GLContext::Extensions_End
|
||||
}
|
||||
},
|
||||
{
|
||||
"robust_buffer_access_behavior",
|
||||
GLVersion::NONE,
|
||||
GLESVersion::NONE,
|
||||
GLContext::Extension_None,
|
||||
{
|
||||
GLContext::ARB_robust_buffer_access_behavior,
|
||||
GLContext::KHR_robust_buffer_access_behavior,
|
||||
GLContext::Extensions_End
|
||||
}
|
||||
},
|
||||
{
|
||||
"robustness",
|
||||
GLVersion::NONE,
|
||||
@ -540,6 +551,7 @@ static const FeatureInfo sFeatureInfoArr[] = {
|
||||
{
|
||||
GLContext::ARB_robustness,
|
||||
GLContext::EXT_robustness,
|
||||
GLContext::KHR_robustness,
|
||||
GLContext::Extensions_End
|
||||
}
|
||||
},
|
||||
|
@ -56,8 +56,6 @@ public:
|
||||
|
||||
virtual bool IsDoubleBuffered() const override;
|
||||
|
||||
virtual bool SupportsRobustness() const override;
|
||||
|
||||
virtual bool SwapBuffers() override;
|
||||
|
||||
virtual void GetWSIInfo(nsCString* const out) const override;
|
||||
|
@ -84,7 +84,7 @@ CreateConfig(EGLConfig* aConfig);
|
||||
#define EGL_ATTRIBS_LIST_SAFE_TERMINATION_WORKING_AROUND_BUGS \
|
||||
LOCAL_EGL_NONE, 0, 0, 0
|
||||
|
||||
static EGLint gTerminationAttribs[] = {
|
||||
static EGLint kTerminationAttribs[] = {
|
||||
EGL_ATTRIBS_LIST_SAFE_TERMINATION_WORKING_AROUND_BUGS
|
||||
};
|
||||
|
||||
@ -482,31 +482,38 @@ GLContextEGL::CreateGLContext(CreateContextFlags flags,
|
||||
EGLContext eglShareContext = shareContext ? shareContext->mContext
|
||||
: EGL_NO_CONTEXT;
|
||||
|
||||
nsTArray<EGLint> contextAttribs;
|
||||
std::vector<EGLint> contextAttribs;
|
||||
|
||||
contextAttribs.AppendElement(LOCAL_EGL_CONTEXT_CLIENT_VERSION);
|
||||
contextAttribs.push_back(LOCAL_EGL_CONTEXT_CLIENT_VERSION);
|
||||
if (flags & CreateContextFlags::PREFER_ES3)
|
||||
contextAttribs.AppendElement(3);
|
||||
contextAttribs.push_back(3);
|
||||
else
|
||||
contextAttribs.AppendElement(2);
|
||||
contextAttribs.push_back(2);
|
||||
|
||||
if (sEGLLibrary.HasRobustness()) {
|
||||
// contextAttribs.AppendElement(LOCAL_EGL_CONTEXT_ROBUST_ACCESS_EXT);
|
||||
// contextAttribs.AppendElement(LOCAL_EGL_TRUE);
|
||||
if (sEGLLibrary.IsExtensionSupported(GLLibraryEGL::KHR_create_context)) {
|
||||
contextAttribs.push_back(LOCAL_EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR);
|
||||
contextAttribs.push_back(LOCAL_EGL_LOSE_CONTEXT_ON_RESET_KHR);
|
||||
contextAttribs.push_back(LOCAL_EGL_CONTEXT_FLAGS_KHR);
|
||||
contextAttribs.push_back(LOCAL_EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR);
|
||||
} else if (sEGLLibrary.IsExtensionSupported(GLLibraryEGL::EXT_create_context_robustness)) {
|
||||
contextAttribs.push_back(LOCAL_EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT);
|
||||
contextAttribs.push_back(LOCAL_EGL_LOSE_CONTEXT_ON_RESET_EXT);
|
||||
contextAttribs.push_back(LOCAL_EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT);
|
||||
contextAttribs.push_back(LOCAL_EGL_TRUE);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < MOZ_ARRAY_LENGTH(gTerminationAttribs); i++) {
|
||||
contextAttribs.AppendElement(gTerminationAttribs[i]);
|
||||
for (const auto& cur : kTerminationAttribs) {
|
||||
contextAttribs.push_back(cur);
|
||||
}
|
||||
|
||||
EGLContext context = sEGLLibrary.fCreateContext(EGL_DISPLAY(),
|
||||
config,
|
||||
eglShareContext,
|
||||
contextAttribs.Elements());
|
||||
contextAttribs.data());
|
||||
if (!context && shareContext) {
|
||||
shareContext = nullptr;
|
||||
context = sEGLLibrary.fCreateContext(EGL_DISPLAY(), config, EGL_NO_CONTEXT,
|
||||
contextAttribs.Elements());
|
||||
contextAttribs.data());
|
||||
}
|
||||
if (!context) {
|
||||
*out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_EGL_CREATE");
|
||||
@ -547,8 +554,8 @@ TRY_AGAIN_POWER_OF_TWO:
|
||||
pbattrs.AppendElement(bindToTextureFormat);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < MOZ_ARRAY_LENGTH(gTerminationAttribs); i++) {
|
||||
pbattrs.AppendElement(gTerminationAttribs[i]);
|
||||
for (const auto& cur : kTerminationAttribs) {
|
||||
pbattrs.AppendElement(cur);
|
||||
}
|
||||
|
||||
surface = sEGLLibrary.fCreatePbufferSurface(EGL_DISPLAY(), config, &pbattrs[0]);
|
||||
|
@ -511,9 +511,11 @@ GLContextGLX::CreateGLContext(CreateContextFlags flags, const SurfaceCaps& caps,
|
||||
if (glx.HasCreateContextAttribs()) {
|
||||
AutoTArray<int, 11> attrib_list;
|
||||
if (glx.HasRobustness()) {
|
||||
int robust_attribs[] = {
|
||||
LOCAL_GL_CONTEXT_FLAGS_ARB, LOCAL_GL_CONTEXT_ROBUST_ACCESS_BIT_ARB,
|
||||
LOCAL_GL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, LOCAL_GL_LOSE_CONTEXT_ON_RESET_ARB,
|
||||
const int robust_attribs[] = {
|
||||
LOCAL_GLX_CONTEXT_FLAGS_ARB,
|
||||
LOCAL_GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB,
|
||||
LOCAL_GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB,
|
||||
LOCAL_GLX_LOSE_CONTEXT_ON_RESET_ARB,
|
||||
};
|
||||
attrib_list.AppendElements(robust_attribs, MOZ_ARRAY_LENGTH(robust_attribs));
|
||||
}
|
||||
@ -662,12 +664,6 @@ GLContextGLX::IsDoubleBuffered() const
|
||||
return mDoubleBuffered;
|
||||
}
|
||||
|
||||
bool
|
||||
GLContextGLX::SupportsRobustness() const
|
||||
{
|
||||
return mGLX->HasRobustness();
|
||||
}
|
||||
|
||||
bool
|
||||
GLContextGLX::SwapBuffers()
|
||||
{
|
||||
|
@ -361,12 +361,6 @@ GLContextWGL::IsDoubleBuffered() const
|
||||
return mIsDoubleBuffered;
|
||||
}
|
||||
|
||||
bool
|
||||
GLContextWGL::SupportsRobustness() const
|
||||
{
|
||||
return sWGLLib.HasRobustness();
|
||||
}
|
||||
|
||||
bool
|
||||
GLContextWGL::SwapBuffers() {
|
||||
if (!mIsDoubleBuffered)
|
||||
|
@ -53,8 +53,6 @@ public:
|
||||
|
||||
virtual bool IsDoubleBuffered() const override;
|
||||
|
||||
virtual bool SupportsRobustness() const override;
|
||||
|
||||
virtual bool SwapBuffers() override;
|
||||
|
||||
virtual bool SetupLookupFunction() override;
|
||||
|
@ -75,6 +75,9 @@
|
||||
#define LOCAL_WGL_ACCESS_READ_WRITE 0x0001
|
||||
#define LOCAL_WGL_ACCESS_WRITE_DISCARD 0x0002
|
||||
|
||||
// GL_KHR_robustness
|
||||
#define LOCAL_GL_CONTEXT_ROBUST_ACCESS 0x90F3
|
||||
|
||||
// Others
|
||||
#define LOCAL_EGL_PRESERVED_RESOURCES 0x3030
|
||||
#define LOCAL_EGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_EXT 0x3138
|
||||
|
@ -52,7 +52,8 @@ static const char* sEGLExtensionNames[] = {
|
||||
"EGL_ANDROID_image_crop",
|
||||
"EGL_ANGLE_platform_angle",
|
||||
"EGL_ANGLE_platform_angle_d3d",
|
||||
"EGL_ANGLE_d3d_share_handle_client_buffer"
|
||||
"EGL_ANGLE_d3d_share_handle_client_buffer",
|
||||
"EGL_KHR_create_context",
|
||||
};
|
||||
|
||||
#if defined(ANDROID)
|
||||
|
@ -105,6 +105,7 @@ public:
|
||||
ANGLE_platform_angle,
|
||||
ANGLE_platform_angle_d3d,
|
||||
ANGLE_d3d_share_handle_client_buffer,
|
||||
KHR_create_context,
|
||||
Extensions_Max
|
||||
};
|
||||
|
||||
@ -327,10 +328,6 @@ public:
|
||||
return IsExtensionSupported(ANGLE_surface_d3d_texture_2d_share_handle);
|
||||
}
|
||||
|
||||
bool HasRobustness() const {
|
||||
return IsExtensionSupported(EXT_create_context_robustness);
|
||||
}
|
||||
|
||||
bool ReadbackEGLImage(EGLImage image, gfx::DataSourceSurface* out_surface);
|
||||
|
||||
bool EnsureInitialized(bool forceAccel, nsACString* const out_failureId);
|
||||
|
@ -629,6 +629,7 @@ private:
|
||||
DECL_GFX_PREF(Live, "webgl.enable-webgl2", WebGL2Enabled, bool, true);
|
||||
DECL_GFX_PREF(Live, "webgl.force-enabled", WebGLForceEnabled, bool, false);
|
||||
DECL_GFX_PREF(Once, "webgl.force-layers-readback", WebGLForceLayersReadback, bool, false);
|
||||
DECL_GFX_PREF(Live, "webgl.force-index-validation", WebGLForceIndexValidation, bool, false);
|
||||
DECL_GFX_PREF(Live, "webgl.lose-context-on-memory-pressure", WebGLLoseContextOnMemoryPressure, bool, false);
|
||||
DECL_GFX_PREF(Live, "webgl.max-warnings-per-context", WebGLMaxWarningsPerContext, uint32_t, 32);
|
||||
DECL_GFX_PREF(Live, "webgl.min_capability_mode", WebGLMinCapabilityMode, bool, false);
|
||||
|
@ -4534,6 +4534,7 @@ pref("webgl.msaa-force", false);
|
||||
pref("webgl.prefer-16bpp", false);
|
||||
pref("webgl.default-no-alpha", false);
|
||||
pref("webgl.force-layers-readback", false);
|
||||
pref("webgl.force-index-validation", false);
|
||||
pref("webgl.lose-context-on-memory-pressure", false);
|
||||
pref("webgl.can-lose-context-in-foreground", true);
|
||||
pref("webgl.restore-context-when-visible", true);
|
||||
|
Loading…
Reference in New Issue
Block a user