Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TEXTURETYPE_UNSIGNED_INT confusion #15905

Merged
merged 2 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/dev/core/src/Collisions/gpuPicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export class GPUPicker {
scene,
false,
undefined,
Constants.TEXTURETYPE_UNSIGNED_INT,
Constants.TEXTURETYPE_UNSIGNED_BYTE,
false,
Constants.TEXTURE_NEAREST_NEAREST
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ ThinEngine.prototype.createMultipleRenderTarget = function (size: TextureSize, o
let textureCount = 1;
let samples = 1;

const defaultType = Constants.TEXTURETYPE_UNSIGNED_INT;
const defaultType = Constants.TEXTURETYPE_UNSIGNED_BYTE;
const defaultSamplingMode = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE;
const defaultUseSRGBBuffer = false;
const defaultFormat = Constants.TEXTUREFORMAT_RGBA;
Expand Down Expand Up @@ -245,7 +245,7 @@ ThinEngine.prototype.createMultipleRenderTarget = function (size: TextureSize, o

const filters = this._getSamplingParameters(samplingMode, generateMipMaps);
if (type === Constants.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
type = Constants.TEXTURETYPE_UNSIGNED_INT;
type = Constants.TEXTURETYPE_UNSIGNED_BYTE;
Logger.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
}

Expand Down Expand Up @@ -335,13 +335,13 @@ ThinEngine.prototype.createMultipleRenderTarget = function (size: TextureSize, o
glDepthTextureType = gl.FLOAT;
glDepthTextureInternalFormat = gl.DEPTH_COMPONENT32F;
} else if (depthTextureFormat === Constants.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8) {
depthTextureType = Constants.TEXTURETYPE_UNSIGNED_INT;
depthTextureType = Constants.TEXTURETYPE_UNSIGNED_BYTE;
glDepthTextureType = gl.FLOAT_32_UNSIGNED_INT_24_8_REV;
glDepthTextureInternalFormat = gl.DEPTH32F_STENCIL8;
glDepthTextureFormat = gl.DEPTH_STENCIL;
glDepthTextureAttachment = gl.DEPTH_STENCIL_ATTACHMENT;
} else if (depthTextureFormat === Constants.TEXTUREFORMAT_DEPTH24) {
depthTextureType = Constants.TEXTURETYPE_UNSIGNED_INT;
depthTextureType = Constants.TEXTURETYPE_UNSIGNED_BYTE;
glDepthTextureType = gl.UNSIGNED_INT;
glDepthTextureInternalFormat = gl.DEPTH_COMPONENT24;
glDepthTextureAttachment = gl.DEPTH_ATTACHMENT;
Expand Down
24 changes: 12 additions & 12 deletions packages/dev/core/src/Engines/Extensions/engine.rawTexture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ declare module "../abstractEngine" {
* @param format defines the format of the data
* @param invertY defines if data must be stored with Y axis inverted
* @param compression defines the compression used (null by default)
* @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
* @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_BYTE by default)
* @param useSRGBBuffer defines if the texture must be loaded in a sRGB GPU buffer (if supported by the GPU).
*/
updateRawTexture(
Expand All @@ -42,7 +42,7 @@ declare module "../abstractEngine" {
* @param texture defines the texture to update
* @param data defines the data to store
* @param format defines the data format
* @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
* @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_BYTE by default)
* @param invertY defines if data must be stored with Y axis inverted
*/
updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
Expand All @@ -52,7 +52,7 @@ declare module "../abstractEngine" {
* @param texture defines the texture to update
* @param data defines the data to store
* @param format defines the data format
* @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
* @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_BYTE by default)
* @param invertY defines if data must be stored with Y axis inverted
* @param compression defines the compression used (null by default)
*/
Expand All @@ -63,7 +63,7 @@ declare module "../abstractEngine" {
* @param texture defines the texture to update
* @param data defines the data to store
* @param format defines the data format
* @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
* @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_BYTE by default)
* @param invertY defines if data must be stored with Y axis inverted
* @param compression defines the compression used (null by default)
* @param level defines which level of the texture to update
Expand All @@ -76,7 +76,7 @@ declare module "../abstractEngine" {
* @param scene defines the current scene
* @param size defines the size of the textures
* @param format defines the format of the data
* @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
* @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_BYTE)
* @param noMipmap defines if the engine should avoid generating the mip levels
* @param callback defines a callback used to extract texture data from loaded data
* @param mipmapGenerator defines to provide an optional tool to generate mip levels
Expand All @@ -103,7 +103,7 @@ declare module "../abstractEngine" {
* @param scene defines the current scene
* @param size defines the size of the textures
* @param format defines the format of the data
* @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
* @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_BYTE)
* @param noMipmap defines if the engine should avoid generating the mip levels
* @param callback defines a callback used to extract texture data from loaded data
* @param mipmapGenerator defines to provide an optional tool to generate mip levels
Expand Down Expand Up @@ -144,7 +144,7 @@ declare module "../abstractEngine" {
* @param format defines the data format
* @param invertY defines if data must be stored with Y axis inverted
* @param compression defines the used compression (can be null)
* @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
* @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_BYTE, Engine.TEXTURETYPE_FLOAT...)
*/
updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;

Expand All @@ -164,7 +164,7 @@ declare module "../abstractEngine" {
* @param format defines the data format
* @param invertY defines if data must be stored with Y axis inverted
* @param compression defines the used compression (can be null)
* @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
* @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_BYTE, Engine.TEXTURETYPE_FLOAT...)
*/
updateRawTexture2DArray(
texture: InternalTexture,
Expand All @@ -183,7 +183,7 @@ ThinEngine.prototype.updateRawTexture = function (
format: number,
invertY: boolean,
compression: Nullable<string> = null,
type: number = Constants.TEXTURETYPE_UNSIGNED_INT,
type: number = Constants.TEXTURETYPE_UNSIGNED_BYTE,
useSRGBBuffer: boolean = false
): void {
if (!texture) {
Expand Down Expand Up @@ -233,7 +233,7 @@ ThinEngine.prototype.createRawTexture = function (
invertY: boolean,
samplingMode: number,
compression: Nullable<string> = null,
type: number = Constants.TEXTURETYPE_UNSIGNED_INT,
type: number = Constants.TEXTURETYPE_UNSIGNED_BYTE,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
creationFlags = 0,
useSRGBBuffer = false
Expand Down Expand Up @@ -597,7 +597,7 @@ function _makeCreateRawTextureFunction(is3D: boolean) {
invertY: boolean,
samplingMode: number,
compression: Nullable<string> = null,
textureType: number = Constants.TEXTURETYPE_UNSIGNED_INT
textureType: number = Constants.TEXTURETYPE_UNSIGNED_BYTE
): InternalTexture {
const target = is3D ? this._gl.TEXTURE_3D : this._gl.TEXTURE_2D_ARRAY;
const source = is3D ? InternalTextureSource.Raw3D : InternalTextureSource.Raw2DArray;
Expand Down Expand Up @@ -664,7 +664,7 @@ function _makeUpdateRawTextureFunction(is3D: boolean) {
format: number,
invertY: boolean,
compression: Nullable<string> = null,
textureType: number = Constants.TEXTURETYPE_UNSIGNED_INT
textureType: number = Constants.TEXTURETYPE_UNSIGNED_BYTE
): void {
const target = is3D ? this._gl.TEXTURE_3D : this._gl.TEXTURE_2D_ARRAY;
const internalType = this._getWebGLTextureType(textureType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ ThinEngine.prototype._setupDepthStencilTexture = function (
internalTexture.samples = samples;
internalTexture.generateMipMaps = false;
internalTexture.samplingMode = bilinearFiltering ? Constants.TEXTURE_BILINEAR_SAMPLINGMODE : Constants.TEXTURE_NEAREST_SAMPLINGMODE;
internalTexture.type = Constants.TEXTURETYPE_UNSIGNED_INT;
internalTexture.type = Constants.TEXTURETYPE_UNSIGNED_BYTE;
internalTexture._comparisonFunction = comparisonFunction;

const gl = this._gl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ThinEngine.prototype.createRenderTargetCubeTexture = function (size: number, opt
generateMipMaps: true,
generateDepthBuffer: true,
generateStencilBuffer: false,
type: Constants.TEXTURETYPE_UNSIGNED_INT,
type: Constants.TEXTURETYPE_UNSIGNED_BYTE,
samplingMode: Constants.TEXTURE_TRILINEAR_SAMPLINGMODE,
format: Constants.TEXTUREFORMAT_RGBA,
...options,
Expand All @@ -47,7 +47,7 @@ ThinEngine.prototype.createRenderTargetCubeTexture = function (size: number, opt
const filters = this._getSamplingParameters(fullOptions.samplingMode, fullOptions.generateMipMaps);

if (fullOptions.type === Constants.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
fullOptions.type = Constants.TEXTURETYPE_UNSIGNED_INT;
fullOptions.type = Constants.TEXTURETYPE_UNSIGNED_BYTE;
Logger.Warn("Float textures are not supported. Cube render target forced to TEXTURETYPE_UNESIGNED_BYTE type");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ WebGPUEngine.prototype.createMultipleRenderTarget = function (size: TextureSize,
}

if (type === Constants.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
type = Constants.TEXTURETYPE_UNSIGNED_INT;
type = Constants.TEXTURETYPE_UNSIGNED_BYTE;
Logger.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ declare module "../../abstractEngine" {
* @param format defines the format of the data
* @param invertY defines if data must be stored with Y axis inverted
* @param compression defines the compression used (null by default)
* @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
* @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_BYTE by default)
* @param useSRGBBuffer defines if the texture must be loaded in a sRGB GPU buffer (if supported by the GPU).
*/
updateRawTexture(
Expand All @@ -44,7 +44,7 @@ declare module "../../abstractEngine" {
* @param data defines the array of data to use to create each face
* @param size defines the size of the textures
* @param format defines the format of the data
* @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
* @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_BYTE)
* @param generateMipMaps defines if the engine should generate the mip levels
* @param invertY defines if data must be stored with Y axis inverted
* @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
Expand All @@ -67,7 +67,7 @@ declare module "../../abstractEngine" {
* @param texture defines the texture to update
* @param data defines the data to store
* @param format defines the data format
* @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
* @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_BYTE by default)
* @param invertY defines if data must be stored with Y axis inverted
*/
updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
Expand All @@ -77,7 +77,7 @@ declare module "../../abstractEngine" {
* @param texture defines the texture to update
* @param data defines the data to store
* @param format defines the data format
* @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
* @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_BYTE by default)
* @param invertY defines if data must be stored with Y axis inverted
* @param compression defines the compression used (null by default)
*/
Expand All @@ -88,7 +88,7 @@ declare module "../../abstractEngine" {
* @param texture defines the texture to update
* @param data defines the data to store
* @param format defines the data format
* @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
* @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_BYTE by default)
* @param invertY defines if data must be stored with Y axis inverted
* @param compression defines the compression used (null by default)
* @param level defines which level of the texture to update
Expand All @@ -101,7 +101,7 @@ declare module "../../abstractEngine" {
* @param scene defines the current scene
* @param size defines the size of the textures
* @param format defines the format of the data
* @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
* @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_BYTE)
* @param noMipmap defines if the engine should avoid generating the mip levels
* @param callback defines a callback used to extract texture data from loaded data
* @param mipmapGenerator defines to provide an optional tool to generate mip levels
Expand All @@ -128,7 +128,7 @@ declare module "../../abstractEngine" {
* @param scene defines the current scene
* @param size defines the size of the textures
* @param format defines the format of the data
* @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
* @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_BYTE)
* @param noMipmap defines if the engine should avoid generating the mip levels
* @param callback defines a callback used to extract texture data from loaded data
* @param mipmapGenerator defines to provide an optional tool to generate mip levels
Expand Down Expand Up @@ -169,7 +169,7 @@ declare module "../../abstractEngine" {
* @param format defines the data format
* @param invertY defines if data must be stored with Y axis inverted
* @param compression defines the used compression (can be null)
* @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
* @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_BYTE, Engine.TEXTURETYPE_FLOAT...)
*/
updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;

Expand All @@ -189,7 +189,7 @@ declare module "../../abstractEngine" {
* @param format defines the data format
* @param invertY defines if data must be stored with Y axis inverted
* @param compression defines the used compression (can be null)
* @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
* @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_BYTE, Engine.TEXTURETYPE_FLOAT...)
*/
updateRawTexture2DArray(
texture: InternalTexture,
Expand All @@ -211,7 +211,7 @@ ThinWebGPUEngine.prototype.createRawTexture = function (
invertY: boolean,
samplingMode: number,
compression: Nullable<string> = null,
type: number = Constants.TEXTURETYPE_UNSIGNED_INT,
type: number = Constants.TEXTURETYPE_UNSIGNED_BYTE,
creationFlags: number = 0,
useSRGBBuffer: boolean = false
): InternalTexture {
Expand Down Expand Up @@ -248,7 +248,7 @@ ThinWebGPUEngine.prototype.updateRawTexture = function (
format: number,
invertY: boolean,
compression: Nullable<string> = null,
type: number = Constants.TEXTURETYPE_UNSIGNED_INT,
type: number = Constants.TEXTURETYPE_UNSIGNED_BYTE,
useSRGBBuffer: boolean = false
): void {
if (!texture) {
Expand Down Expand Up @@ -464,7 +464,7 @@ ThinWebGPUEngine.prototype.createRawTexture3D = function (
invertY: boolean,
samplingMode: number,
compression: Nullable<string> = null,
textureType: number = Constants.TEXTURETYPE_UNSIGNED_INT,
textureType: number = Constants.TEXTURETYPE_UNSIGNED_BYTE,
creationFlags: number = 0
): InternalTexture {
const source = InternalTextureSource.Raw3D;
Expand Down Expand Up @@ -502,7 +502,7 @@ ThinWebGPUEngine.prototype.updateRawTexture3D = function (
format: number,
invertY: boolean,
compression: Nullable<string> = null,
textureType: number = Constants.TEXTURETYPE_UNSIGNED_INT
textureType: number = Constants.TEXTURETYPE_UNSIGNED_BYTE
): void {
if (!this._doNotHandleContextLost) {
texture._bufferView = bufferView;
Expand Down Expand Up @@ -540,7 +540,7 @@ ThinWebGPUEngine.prototype.createRawTexture2DArray = function (
invertY: boolean,
samplingMode: number,
compression: Nullable<string> = null,
textureType: number = Constants.TEXTURETYPE_UNSIGNED_INT,
textureType: number = Constants.TEXTURETYPE_UNSIGNED_BYTE,
creationFlags: number = 0
): InternalTexture {
const source = InternalTextureSource.Raw2DArray;
Expand Down Expand Up @@ -578,7 +578,7 @@ ThinWebGPUEngine.prototype.updateRawTexture2DArray = function (
format: number,
invertY: boolean,
compression: Nullable<string> = null,
textureType: number = Constants.TEXTURETYPE_UNSIGNED_INT
textureType: number = Constants.TEXTURETYPE_UNSIGNED_BYTE
): void {
if (!this._doNotHandleContextLost) {
texture._bufferView = bufferView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ThinWebGPUEngine.prototype.createRenderTargetCubeTexture = function (size: numbe
generateMipMaps: true,
generateDepthBuffer: true,
generateStencilBuffer: false,
type: Constants.TEXTURETYPE_UNSIGNED_INT,
type: Constants.TEXTURETYPE_UNSIGNED_BYTE,
samplingMode: Constants.TEXTURE_TRILINEAR_SAMPLINGMODE,
format: Constants.TEXTUREFORMAT_RGBA,
samples: 1,
Expand Down
Loading