Commit 315ecd20 by Jamie Madill

Add entry points for EGL_ANGLE_program_cache_control.

This instruments the plumbing for the extension without adding any functionality or exposing the extensions string. The extension text is also updated to reflect the new entry point design and naming. Also this corrects a few mistakes. This will be followed up by the tests (which won't run) and then the extension functionality in ANGLE. BUG=angleproject:1897 Change-Id: I5b009e23bc27da06b067375525bd6fc574027702
parent 37d96cce
......@@ -52,7 +52,7 @@ New Tokens
Accepted by the <cap> parameter to IsEnabled and the <pname> parameter to
GetBooleanv, GetIntegerv, GetFloatv, and GetInteger64v:
PROGRAM_CACHE_ENABLED_ANGLE
PROGRAM_CACHE_ENABLED_ANGLE 0x93AC
Additions to the OpenGL ES Specification:
......
......@@ -47,62 +47,49 @@ New Types
New Procedures and Functions
void eglGetProgramCacheAttribANGLE(
EGLint eglProgramCacheGetAttribANGLE(
EGLDisplay dpy,
EGLenum attrib,
EGLint *value);
EGLenum attrib);
void eglQueryProgramCacheANGLE(
void eglProgramCacheQueryANGLE(
EGLDisplay dpy,
EGLint index,
void *key,
EGLint *keysize,
void *binary,
EGLint *size);
EGLint *binarysize);
void eglPopulateProgramCacheANGLE(
void eglProgramCachePopulateANGLE(
EGLDisplay dpy,
void *key,
const void *key,
EGLint keysize,
void *binary,
const void *binary,
EGLint binarysize);
EGLint eglTrimProgramCacheANGLE(
EGLint eglProgramCacheResizeANGLE(
EGLDisplay dpy,
EGLint limit);
EGLint limit,
EGLenum mode);
New Tokens
Accepted as a value for 'attrib' in eglGetProgramCacheAttribANGLE:
Accepted as a value for 'attrib' in eglProgramCacheGetAttribANGLE:
EGL_PROGRAM_CACHE_SIZE_ANGLE 0xXXXX
EGL_PROGRAM_CACHE_KEY_LENGTH_ANGLE 0xXXXX
EGL_PROGRAM_CACHE_SIZE_ANGLE 0x3455
EGL_PROGRAM_CACHE_KEY_LENGTH_ANGLE 0x3456
Accepted as an attribute name in the <*attrib_list> argument to
eglGetPlatformDisplay:
Accepted as a value for 'mode' in eglProgramCacheResizeANGLE:
EGL_DISPLAY_PROGRAM_BINARY_CACHE_MAX_SIZE_ANGLE 0xXXXX
EGL_PROGRAM_CACHE_RESIZE_ANGLE 0x3457
EGL_PROGRAM_CACHE_TRIM_ANGLE 0x3458
Accepted as an attribute name in the <*attrib_list> argument to
eglCreateContext:
EGL_CONTEXT_PROGRAM_BINARY_CACHE_ENABLED_ANGLE 0xXXXX
EGL_CONTEXT_PROGRAM_BINARY_CACHE_ENABLED_ANGLE 0x3459
Additions to the EGL 1.5 Specification
Add a new section entitled "OpenGL ES Program Cache Initialization"
to section 3.2:
If the attribute EGL_DISPLAY_PROGRAM_BINARY_CACHE_MAX_SIZE_ANGLE is set to a
positive number, a Display supporting a program binary cache will be
returned. OpenGL ES contexts created on this display must support the
ANGLE_program_cache_control extension, or equivalent core API functionality.
The maximum size, in bytes, of the cache will be set to the value of
EGL_DISPLAY_PROGRAM_BINARY_CACHE_MAX_SIZE_ANGLE. If
EGL_DISPLAY_PROGRAM_BINARY_CACHE_MAX_SIZE_ANGLE is zero, program caching is
disabled. The default value of
EGL_DISPLAY_PROGRAM_BINARY_CACHE_MAX_SIZE_ANGLE is implementation-dependent.
Add the following to section 3.7.1 "Creating Rendering Contexts":
EGL_CONTEXT_PROGRAM_BINARY_CACHE_ENABLED_ANGLE indicates whether the context
......@@ -122,21 +109,20 @@ Additions to the EGL 1.5 Specification
Program binary cache properties may be queried using
void eglGetProgramCacheAttribANGLE(EGLDisplay dpy, EGLenum attrib,
EGLint *value);
EGLint eglProgramCacheGetAttribANGLE(EGLDisplay dpy, EGLenum attrib);
The only accepted values for 'attrib' are EGL_PROGRAM_CACHE_SIZE_ANGLE and
EGL_PROGRAM_CACHE_KEY_LENGTH_ANGLE. A query for EGL_PROGRAM_CACHE_SIZE_ANGLE
will return the number of cache entries in the program cache in 'value'. A
will return the number of cache entries in the program cache. A
query of EGL_PROGRAM_CACHE_KEY_LENGTH_ANGLE will return the required length
(in bytes) of the 'key' parameter to eglQueryProgramCacheANGLE and
(in bytes) of the 'key' parameter to eglProgramCacheQueryANGLE and
eglPopulateProgramCacheANGLE. Any other value for 'attrib' will produce an
error of EGL_BAD_ATTRIBUTE, and an invalid display for 'dpy' will produce an
error of EGL_BAD_DISPLAY.
error of EGL_BAD_DISPLAY. All error cases will return zero.
Cache contents may be queried by using
void eglQueryProgramCacheANGLE(EGLDisplay dpy, EGLint index,
void eglProgramCacheQueryANGLE(EGLDisplay dpy, EGLint index,
void *key, EGLint *keysize, void *binary, EGLint *binarysize);
If 'dpy' is not a valid display an EGL_BAD_DISPLAY error is generated. If
......@@ -144,8 +130,8 @@ Additions to the EGL 1.5 Specification
EGL_PROGRAM_CACHE_SIZE_ANGLE, an EGL_BAD_PARAMETER error is generated. If
'dpy' is not a valid display EGL_BAD_DISPLAY is generated. If 'binarysize'
and 'keysize' are non-null, and 'binary' and 'key' are null, the size of the
binary at 'index' is written to 'size', and the key size to 'keysize'. If
'binary' is not null, 'binarysize' specifies the maximum size of the
binary at 'index' is written to 'binarysize', and the key size to 'keysize'.
If 'binary' is not null, 'binarysize' specifies the maximum size of the
'binary' out parameter, and if 'keysize' is not null, the size of the 'key'
out parameter. Any attempt to write more than 'binarysize' or 'keysize'
bytes will produce an EGL_BAD_ACCESS error in this case. If 'keysize' or
......@@ -159,26 +145,32 @@ Additions to the EGL 1.5 Specification
The cache may be warmed up on startup with
void eglPopulateProgramCacheANGLE(EGLDisplay dpy, void *key,
EGLint keysize, void *binary, EGLint binarysize);
void eglProgramCachePopulateANGLE(EGLDisplay dpy, const void *key,
EGLint keysize, const void *binary, EGLint binarysize);
If 'dpy' is not a valid display an EGL_BAD_DISPLAY error is generated. If
'binarysize' is negative or greater than an internally defined maximum size,
EGL_BAD_PARAMETER is generated. If 'keysize' does not match the cache key
size of the implementation, EGL_BAD_PARAMETER is generated. If the program
binary is invalid for any reason, behaviour is undefined. Otherwise the
program will be loaded into the internal binary cache with the key 'key'. If
'binary' or 'key' are null, an EGL_BAD_PARAMETER error is generated.
'binarysize' is not positive or is greater than an internally defined
maximum size, EGL_BAD_PARAMETER is generated. If 'keysize' does not equal
EGL_PROGRAM_CACHE_KEY_LENGTH_ANGLE, EGL_BAD_PARAMETER is generated. If the
program binary is invalid for any reason, behaviour is undefined. Otherwise
the program will be loaded into the internal binary cache with the key
'key'. If 'binary' or 'key' are null, an EGL_BAD_PARAMETER error is
generated.
The cache contents may be temporarily released by using
The cache contents size may be changed using
EGLint eglTrimProgramCacheANGLE(EGLDisplay dpy, EGLint limit);
EGLint eglProgramCacheResizeANGLE(EGLDisplay dpy, EGLint limit,
EGLenum mode);
If 'dpy' is not a valid display an EGL_BAD_DISPLAY error is generated. If
limit is negative then EGL_BAD_PARAMETER is generated. In any error case,
zero is returned, otherwise, the command will free cache resources until the
total cache size, in bytes, is less than or equal to limit, and return the
number of bytes of memory released.
limit is negative then EGL_BAD_PARAMETER is generated. If 'mode' is
EGL_PROGRAM_CACHE_RESIZE, cache contents are discarded and a new maximum
cache size is set to 'limit'. If 'limit' is larget than an implementation-
defined internal constant, EGL_BAD_PARAMETER is generated. Otherwise the
initial cache size is returned. If 'mode' is EGL_PROGRAM_CACHE_TRIM, cache
resources are released until the total cache size, in bytes, is less than or
equal to 'limit', and the number of bytes of memory released is returned.
In any error case, zero is returned.
Errors
......@@ -201,6 +193,8 @@ Issues
implementation with other kinds of cache sharing, such as between share
groups.
We can choose to prefer simplicity of design in this case.
RESOLVED: the cache should be a property of the display.
2. What should happen if the cache is modified as the user is querying its
......@@ -211,6 +205,8 @@ Issues
queried. This can be controlled in the application layer. It can also be
locked using OS-level synchronization.
Introducing undefined behaviour can be very problematic.
RESOLVED: we should use a mutex or similar lock to allow for multithreaded
access, and not expose undefined behaviour.
......@@ -226,6 +222,8 @@ Issues
If caches are a property of the display, they could be set in
eglGetPlatformDisplay as an attribute.
Cache controls can be a necessary feature for memory management.
RESOLVED: yes, we should expose cache size controls.
Revision History
......
......@@ -10,6 +10,8 @@
#ifndef INCLUDE_EGL_EGLEXT_ANGLE_
#define INCLUDE_EGL_EGLEXT_ANGLE_
// clang-format off
#ifndef EGL_ANGLE_display_robust_resource_initialization
#define EGL_ANGLE_display_robust_resource_initialization 1
#define EGL_DISPLAY_ROBUST_RESOURCE_INITIALIZATION_ANGLE 0x3453
......@@ -144,4 +146,25 @@ EGLAPI EGLBoolean EGLAPIENTRY eglReleaseDeviceANGLE(EGLDeviceEXT device);
#endif
#endif /* EGL_ANGLE_device_creation */
#ifndef EGL_ANGLE_program_cache_control
#define EGL_ANGLE_program_cache_control 1
#define EGL_PROGRAM_CACHE_SIZE_ANGLE 0x3455
#define EGL_PROGRAM_CACHE_KEY_LENGTH_ANGLE 0x3456
#define EGL_PROGRAM_CACHE_RESIZE_ANGLE 0x3457
#define EGL_PROGRAM_CACHE_TRIM_ANGLE 0x3458
#define EGL_CONTEXT_PROGRAM_BINARY_CACHE_ENABLED_ANGLE 0x3459
typedef EGLint (EGLAPIENTRYP PFNEGLPROGRAMCACHEGETATTRIBANGLEPROC) (EGLDisplay dpy, EGLenum attrib);
typedef void (EGLAPIENTRYP PFNEGLPROGRAMCACHEQUERYANGLEPROC) (EGLDisplay dpy, EGLint index, void *key, EGLint *keysize, void *binary, EGLint *binarysize);
typedef void (EGLAPIENTRYP PFNEGPROGRAMCACHELPOPULATEANGLEPROC) (EGLDisplay dpy, const void *key, EGLint keysize, const void *binary, EGLint binarysize);
typedef EGLint (EGLAPIENTRYP PFNEGLPROGRAMCACHERESIZEANGLEPROC) (EGLDisplay dpy, EGLint limit, EGLenum mode);
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLint EGLAPIENTRY eglProgramCacheGetAttribANGLE(EGLDisplay dpy, EGLenum attrib);
EGLAPI void EGLAPIENTRY eglProgramCacheQueryANGLE(EGLDisplay dpy, EGLint index, void *key, EGLint *keysize, void *binary, EGLint *binarysize);
EGLAPI void EGLAPIENTRY eglProgramCachePopulateANGLE(EGLDisplay dpy, const void *key, EGLint keysize, const void *binary, EGLint binarysize);
EGLAPI EGLint EGLAPIENTRY eglProgramCacheResizeANGLE(EGLDisplay dpy, EGLint limit, EGLenum mode);
#endif
#endif /* EGL_ANGLE_program_cache_control */
// clang-format on
#endif // INCLUDE_EGL_EGLEXT_ANGLE_
......@@ -10,6 +10,8 @@
#ifndef INCLUDE_GLES2_GL2EXT_ANGLE_H_
#define INCLUDE_GLES2_GL2EXT_ANGLE_H_
// clang-format off
#ifndef GL_ANGLE_client_arrays
#define GL_ANGLE_client_arrays 1
#define GL_CLIENT_ARRAYS_ANGLE 0x93AA
......@@ -511,4 +513,11 @@ GL_APICALL void GL_APIENTRY glGetQueryObjectui64vRobustANGLE(GLuint id, GLenum p
#endif
#endif /* GL_ANGLE_robust_client_memory */
#ifndef GL_ANGLE_program_cache_control
#define GL_ANGLE_program_cache_control 1
#define GL_PROGRAM_CACHE_ENABLED_ANGLE 0x93AC
#endif /* GL_ANGLE_program_cache_control */
// clang-format on
#endif // INCLUDE_GLES2_GL2EXT_ANGLE_H_
......@@ -226,7 +226,8 @@ Extensions::Extensions()
pathRendering(false),
surfacelessContext(false),
clientArrays(false),
robustResourceInitialization(false)
robustResourceInitialization(false),
programCacheControl(false)
{
}
......@@ -694,6 +695,7 @@ const ExtensionInfoMap &GetExtensionInfoMap()
map["GL_OES_surfaceless_context"] = esOnlyExtension(&Extensions::surfacelessContext);
map["GL_ANGLE_client_arrays"] = esOnlyExtension(&Extensions::clientArrays);
map["GL_ANGLE_robust_resource_initialization"] = esOnlyExtension(&Extensions::robustResourceInitialization);
map["GL_ANGLE_program_cache_control"] = esOnlyExtension(&Extensions::programCacheControl);
// clang-format on
return map;
......@@ -1084,7 +1086,8 @@ DisplayExtensions::DisplayExtensions()
pixelFormatFloat(false),
surfacelessContext(false),
displayTextureShareGroup(false),
createContextClientArrays(false)
createContextClientArrays(false),
programCacheControl(false)
{
}
......@@ -1127,6 +1130,7 @@ std::vector<std::string> DisplayExtensions::getStrings() const
InsertExtensionString("EGL_KHR_surfaceless_context", surfacelessContext, &extensionStrings);
InsertExtensionString("EGL_ANGLE_display_texture_share_group", displayTextureShareGroup, &extensionStrings);
InsertExtensionString("EGL_ANGLE_create_context_client_arrays", createContextClientArrays, &extensionStrings);
InsertExtensionString("EGL_ANGLE_program_cache_control", programCacheControl, &extensionStrings);
// TODO(jmadill): Enable this when complete.
//InsertExtensionString("KHR_create_context_no_error", createContextNoError, &extensionStrings);
// clang-format on
......
......@@ -363,6 +363,9 @@ struct Extensions
// GL_ANGLE_robust_resource_initialization
bool robustResourceInitialization;
// GL_ANGLE_program_cache_control
bool programCacheControl;
};
struct ExtensionInfo
......@@ -667,6 +670,9 @@ struct DisplayExtensions
// EGL_ANGLE_create_context_client_arrays
bool createContextClientArrays;
// EGL_ANGLE_program_cache_control
bool programCacheControl;
};
struct DeviceExtensions
......
......@@ -375,4 +375,34 @@ EGLBoolean EGLAPIENTRY eglSwapBuffersWithDamageEXT(EGLDisplay dpy,
{
return egl::SwapBuffersWithDamageEXT(dpy, surface, rects, n_rects);
}
EGLint EGLAPIENTRY eglProgramCacheGetAttribANGLE(EGLDisplay dpy, EGLenum attrib)
{
return egl::ProgramCacheGetAttribANGLE(dpy, attrib);
}
void EGLAPIENTRY eglProgramCacheQueryANGLE(EGLDisplay dpy,
EGLint index,
void *key,
EGLint *keysize,
void *binary,
EGLint *binarysize)
{
egl::ProgramCacheQueryANGLE(dpy, index, key, keysize, binary, binarysize);
}
void EGLAPIENTRY eglProgramCachePopulateANGLE(EGLDisplay dpy,
const void *key,
EGLint keysize,
const void *binary,
EGLint binarysize)
{
egl::ProgramCachePopulateANGLE(dpy, key, keysize, binary, binarysize);
}
EGLint EGLAPIENTRY eglProgramCacheResizeANGLE(EGLDisplay dpy, EGLint limit, EGLenum mode)
{
return egl::ProgramCacheResizeANGLE(dpy, limit, mode);
}
} // extern "C"
......@@ -59,6 +59,10 @@ EXPORTS
eglStreamPostD3DTextureNV12ANGLE @65
eglGetSyncValuesCHROMIUM @66
eglSwapBuffersWithDamageEXT @67
eglProgramCacheGetAttribANGLE @68
eglProgramCachePopulateANGLE @69
eglProgramCacheQueryANGLE @70
eglProgramCacheResizeANGLE @71
; 1.5 entry points
eglCreateSync @38
......
......@@ -1909,6 +1909,12 @@ __eglMustCastToProperFunctionPointerType EGLAPIENTRY GetProcAddress(const char *
// EGL_EXT_swap_buffers_with_damage
INSERT_PROC_ADDRESS(egl, SwapBuffersWithDamageEXT);
// EGL_ANGLE_program_cache_control
INSERT_PROC_ADDRESS(egl, ProgramCacheGetAttribANGLE);
INSERT_PROC_ADDRESS(egl, ProgramCacheQueryANGLE);
INSERT_PROC_ADDRESS(egl, ProgramCachePopulateANGLE);
INSERT_PROC_ADDRESS(egl, ProgramCacheResizeANGLE);
// angle::Platform related entry points
INSERT_PROC_ADDRESS_NO_NS("ANGLEGetDisplayPlatform", ANGLEGetDisplayPlatform);
INSERT_PROC_ADDRESS_NO_NS("ANGLEResetDisplayPlatform", ANGLEResetDisplayPlatform);
......
......@@ -785,4 +785,49 @@ ANGLE_EXPORT EGLBoolean SwapBuffersWithDamageEXT(EGLDisplay dpy,
return EGL_TRUE;
}
EGLint EGLAPIENTRY ProgramCacheGetAttribANGLE(EGLDisplay dpy, EGLenum attrib)
{
EVENT("(EGLDisplay dpy = 0x%0.8p, EGLenum attrib = 0x%X)", dpy, attrib);
UNIMPLEMENTED();
return 0;
}
void EGLAPIENTRY ProgramCacheQueryANGLE(EGLDisplay dpy,
EGLint index,
void *key,
EGLint *keysize,
void *binary,
EGLint *binarysize)
{
EVENT(
"(EGLDisplay dpy = 0x%0.8p, EGLint index = %d, void *key = 0x%0.8p, EGLint *keysize = "
"0x%0.8p, void *binary = 0x%0.8p, EGLint *size = 0x%0.8p)",
dpy, index, key, keysize, binary, binarysize);
UNIMPLEMENTED();
}
void EGLAPIENTRY ProgramCachePopulateANGLE(EGLDisplay dpy,
const void *key,
EGLint keysize,
const void *binary,
EGLint binarysize)
{
EVENT(
"(EGLDisplay dpy = 0x%0.8p, void *key = 0x%0.8p, EGLint keysize = %d, void *binary = "
"0x%0.8p, EGLint *size = 0x%0.8p)",
dpy, key, keysize, binary, binarysize);
UNIMPLEMENTED();
}
EGLint EGLAPIENTRY ProgramCacheResizeANGLE(EGLDisplay dpy, EGLint limit, EGLenum mode)
{
EVENT("(EGLDisplay dpy = 0x%0.8p, EGLint limit = %d, EGLenum mode = 0x%X)", dpy, limit, mode);
UNIMPLEMENTED();
return 0;
}
} // namespace egl
......@@ -93,6 +93,21 @@ ANGLE_EXPORT EGLBoolean SwapBuffersWithDamageEXT(EGLDisplay dpy,
EGLint *rects,
EGLint n_rects);
//
ANGLE_EXPORT EGLint EGLAPIENTRY ProgramCacheGetAttribANGLE(EGLDisplay dpy, EGLenum attrib);
ANGLE_EXPORT void EGLAPIENTRY ProgramCacheQueryANGLE(EGLDisplay dpy,
EGLint index,
void *key,
EGLint *keysize,
void *binary,
EGLint *binarysize);
ANGLE_EXPORT void EGLAPIENTRY ProgramCachePopulateANGLE(EGLDisplay dpy,
const void *key,
EGLint keysize,
const void *binary,
EGLint binarysize);
ANGLE_EXPORT EGLint EGLAPIENTRY ProgramCacheResizeANGLE(EGLDisplay dpy, EGLint limit, EGLenum mode);
} // namespace egl
#endif // LIBGLESV2_ENTRYPOINTSEGLEXT_H_
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment