// Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved.
//
// SPDX-License-Identifier: CC-BY-4.0

include::{generated}/meta/XR_FB_swapchain_update_state_opengl_es.adoc[]

*Contributors*::
    Cass Everitt, Facebook +
    Gloria Kennickell, Facebook +


*Overview*

This extension enables the application to modify and query OpenGL
ES-specific mutable state associated with a swapchain, examples include:

* On platforms where composition runs in a separate process from the
  application, swapchains must be created in a cross-process friendly way.
  In such cases, the texture image memory may be shared between processes,
  but the texture state may not; and, an explicit mechanism to synchronize
  this texture state between the application and the compositor is required.

In order to enable the functionality of this extension, the application
must: pass the name of the extension into flink:xrCreateInstance via the
slink:XrInstanceCreateInfo pname:enabledExtensionNames parameter as
indicated in the <<fundamentals-extensions>> section.

*New Object Types*

*New Flag Types*

*New Enum Constants*

elink:XrStructureType enumeration is extended with:

* ename:XR_TYPE_SWAPCHAIN_STATE_SAMPLER_OPENGL_ES_FB

*New Enums*

*New Structures*

[open,refpage='XrSwapchainStateSamplerOpenGLESFB',type='structs',desc='OpenGL ES-specific swapchain sampler state structure',xrefs='xrUpdateSwapchainFB xrGetSwapchainStateFB']
--
The slink:XrSwapchainStateSamplerOpenGLESFB structure is defined as:

include::{generated}/api/structs/XrSwapchainStateSamplerOpenGLESFB.adoc[]

.Member Descriptions
****
* pname:type is the elink:XrStructureType of this structure.
* pname:next is code:NULL or a pointer to the next structure in a structure
  chain.
  No such structures are defined in core OpenXR or this extension.
* pname:minFilter is a valid Android OpenGL ES sname:EGLenum.
* pname:magFilter is a valid Android OpenGL ES sname:EGLenum.
* pname:wrapModeS is a valid Android OpenGL ES sname:EGLenum.
* pname:wrapModeT is a valid Android OpenGL ES sname:EGLenum.
* pname:swizzleRed is a valid Android OpenGL ES sname:EGLenum.
* pname:swizzleGreen is a valid Android OpenGL ES sname:EGLenum.
* pname:swizzleBlue is a valid Android OpenGL ES sname:EGLenum.
* pname:swizzleAlpha is a valid Android OpenGL ES sname:EGLenum.
* pname:maxAnisotropy is a valid float used to represent max anisotropy.
* pname:borderColor is an RGBA color to be used as border texels.
****

When slink:XrSwapchainStateSamplerOpenGLESFB is specified in the call to
flink:xrUpdateSwapchainFB, texture sampler state for all images in the
slink:XrSwapchain will be updated for both the application and compositor
processes.

For most cases, the sampler state update is only required compositor-side,
as that is where the swapchain images are sampled.
For completeness, the application-side sampler state is additionally updated
to support cases where the application may choose to directly sample the
swapchain images.

Applications are expected to handle synchronization of the sampler state
update with application-side rendering.
Similarly, the compositor will synchronize the sampler state update with
rendering of the next compositor frame.

An sname:EGLContext, either the sname:EGLContext bound during
slink:XrSwapchain creation or an sname:EGLContext in the same share group,
is required to be bound on the application calling thread.
Current texture bindings may be altered by the call, including the active
texture.

When slink:XrSwapchainStateSamplerOpenGLESFB is specified in the call to
flink:xrGetSwapchainStateFB, the sampler state will be populated with the
current swapchain sampler state.

To use slink:XrSwapchainStateSamplerOpenGLESFB,
dlink:XR_USE_GRAPHICS_API_OPENGL_ES must be defined before including
`openxr_platform.h`.

include::{generated}/validity/structs/XrSwapchainStateSamplerOpenGLESFB.adoc[]
--

*New Functions*

*Issues*

*Version History*

* Revision 1, 2021-05-27 (Gloria Kennickell)
** Initial draft
