Class: SharedTexture
Shared 2D GPU texture that is accessible from the local project and the Adamas runtime.
The underlying shared-memory pixel format is always 8-bit-per-channel
RGBA.
This texture can be used in the same manner as a 2D texture created by
TextureManager.Create2D, including APIs that accept a texture handle for
rendering or material assignment.
Color space is controlled by the linear argument:
false(default): sRGB texturetrue: linear texture
Use uploadRGBA and readLatestRGBA with Uint8Array data in
R, G, B, A byte order.
Accessors
textureHandle
Get Signature
get textureHandle(): number;
Gets the texture handle for this shared texture.
This handle can be passed to other render APIs that accept a texture handle.
Returns
number
width
Get Signature
get width(): number;
Gets the width of the shared texture in pixels.
Returns
number
height
Get Signature
get height(): number;
Gets the height of the shared texture in pixels.
Returns
number
linear
Get Signature
get linear(): boolean;
Gets whether the shared texture uses linear color space.
When false, the shared texture uses sRGB color space.
Returns
boolean
nativeTextureId
Get Signature
get nativeTextureId(): number;
Gets the native texture id for this shared texture.
This value can be forwarded to other native addons that coordinate with the same shared GPU resource.
The underlying native backend is:
- macOS:
metal-iosurface - Windows:
d3d11
Returns
number
Methods
Create()
static Create(
width,
height,
linear): Promise<SharedTexture>;
Creates a shared GPU texture.
The underlying native shared-memory layout is RGBA8.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
width | number | undefined | Texture width in pixels. |
height | number | undefined | Texture height in pixels. |
linear | boolean | false | Whether the shared texture should use linear color space. Defaults to false, which creates an sRGB texture. |
Returns
Promise<SharedTexture>
A promise that resolves to the created shared texture wrapper.
uploadRGBA()
uploadRGBA(rgbaData): Promise<void>;
Uploads a full frame into the shared texture.
The input data must be tightly packed 8-bit RGBA bytes in R, G, B,
A order. The byte length must be exactly width * height * 4.
Parameters
| Parameter | Type | Description |
|---|---|---|
rgbaData | Uint8Array | Raw RGBA8 pixel data for the full texture. |
Returns
Promise<void>
A promise that resolves when the shared texture has been updated.
blitFromRenderTexture()
blitFromRenderTexture(renderTexture): Promise<void>;
Copies a render texture into this shared texture on the runtime side.
Parameters
| Parameter | Type |
|---|---|
renderTexture | number |
Returns
Promise<void>
A promise that resolves when the GPU copy request has completed.
readRGBA()
readRGBA(): Uint8Array;
Reads the latest full frame from the shared texture.
The returned data is tightly packed 8-bit RGBA bytes in R, G, B,
A order, matching the shared texture's true native memory format.
Returns
Uint8Array
The latest full-frame RGBA8 pixel buffer.
close()
close(): Promise<void>;
Destroys the shared texture and releases its native resources.
After this completes, the instance must not be used again.
Returns
Promise<void>
A promise that resolves after both the runtime-side and local native shared-texture resources have been released.