-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
256 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
## TextureView | ||
|
||
A `TextureView` is a view onto some subset of the texture subresources defined by a particular `Texture`. | ||
|
||
### Subresource Selection | ||
|
||
The set of texture subresources of a texture view view, is the subset of the subresources | ||
of the associated `Texture` for which each subresource satisfies the following: | ||
- The mipmap level of s is ≥ props.baseMipLevel and < props.baseMipLevel + props.mipLevelCount. | ||
- The array layer of s is ≥ props.baseArrayLayer and < props.baseArrayLayer + props.arrayLayerCount. | ||
- The aspect of s is in the set of aspects of props.aspect. | ||
|
||
### Render Extent | ||
|
||
There is an implicit "render extent" associated with a renderable `TextureView`. | ||
This render extent depends on the baseMipLevel. | ||
|
||
### TextureView Aliasing | ||
|
||
Two `TextureView` objects are texture-view-aliasing if and only if their sets of subresources intersect. | ||
|
||
## Usage | ||
|
||
```ts | ||
const texture = device.createTexture({...}); | ||
const textureView = texture.createView({...}); | ||
``` | ||
|
||
## Types | ||
|
||
### TextureViewProps | ||
|
||
## Methods | ||
|
||
### `constructor` | ||
|
||
The constructor for `TextureView` should not be called directly. Use `Texture.createView()` instead. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// luma.gl, MIT license | ||
// Copyright (c) vis.gl contributors | ||
|
||
import type {Device} from '../device'; | ||
import type {Texture} from './texture'; | ||
import type {TextureFormat} from '../types/texture-formats'; | ||
import {Resource, ResourceProps} from './resource'; | ||
|
||
/** Properties for initializing a texture view */ | ||
export type TextureViewProps = ResourceProps & { | ||
/** The format of the texture view. Must be either the format of the texture or one of the viewFormats specified during its creation. */ | ||
format?: TextureFormat; | ||
/** The dimension to view the texture as. */ | ||
dimension?: '1d' | '2d' | '2d-array' | 'cube' | 'cube-array' | '3d'; | ||
/** Which aspect(s) of the texture are accessible to the texture view. default "all"*/ | ||
aspect?: 'all' | 'stencil-only' | 'depth-only'; | ||
/** The first (most detailed) mipmap level accessible to the texture view. default 0*/ | ||
baseMipLevel?: number; | ||
/** How many mipmap levels, starting with baseMipLevel, are accessible to the texture view. */ | ||
mipLevelCount: number; | ||
/** The index of the first array layer accessible to the texture view. default 0 */ | ||
baseArrayLayer?: number; | ||
/** How many array layers, starting with baseArrayLayer, are accessible to the texture view. */ | ||
arrayLayerCount: number; | ||
}; | ||
|
||
/** Immutable TextureView object */ | ||
export abstract class TextureView extends Resource<TextureViewProps> { | ||
static override defaultProps: Required<TextureViewProps> = { | ||
...Resource.defaultProps, | ||
format: undefined, | ||
dimension: undefined, | ||
aspect: 'all', | ||
baseMipLevel: 0, | ||
mipLevelCount: undefined, | ||
baseArrayLayer: 0, | ||
arrayLayerCount: undefined | ||
}; | ||
|
||
abstract texture: Texture; | ||
|
||
override get [Symbol.toStringTag](): string { | ||
return 'TextureView'; | ||
} | ||
|
||
/** Should not be constructed directly. Use `texture.createView(props)` */ | ||
constructor(device: Device, props: TextureViewProps & {texture: Texture}) { | ||
super(device, props, TextureView.defaultProps); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// luma.gl, MIT license | ||
// Copyright (c) vis.gl contributors | ||
|
||
import type {Device, TextureViewProps} from '@luma.gl/core'; | ||
// import {decodeTextureFormat} from '@luma.gl/core'; | ||
import {TextureView, Texture} from '@luma.gl/core'; | ||
|
||
import {WebGLDevice} from '../webgl-device'; | ||
import {WEBGLTexture} from './webgl-texture'; | ||
|
||
export class WEBGLTextureView extends TextureView { | ||
readonly device: WebGLDevice; | ||
readonly gl: WebGL2RenderingContext; | ||
readonly handle: WebGLTexture; | ||
|
||
readonly texture: WEBGLTexture; | ||
|
||
constructor(device: Device, props: TextureViewProps & {texture: WEBGLTexture}) { | ||
super(device, {...Texture.defaultProps, ...props}); | ||
|
||
this.device = device as WebGLDevice; | ||
this.gl = this.device.gl; | ||
this.handle = null; | ||
|
||
this.texture = props.texture; | ||
} | ||
} |
Oops, something went wrong.