|
@@ -1000,6 +1000,8 @@ class GlDriver extends Driver {
|
|
|
}
|
|
|
|
|
|
function getBindType( t : h3d.mat.Texture ) {
|
|
|
+ if ( t.flags.has(Is3D) )
|
|
|
+ return GL.TEXTURE_3D;
|
|
|
var isArray = t.flags.has(IsArray);
|
|
|
if( t.flags.has(Cube) )
|
|
|
return #if (hlsdl > version("1.15.0")) isArray ? GL.TEXTURE_CUBE_MAP_ARRAY : #end GL.TEXTURE_CUBE_MAP;
|
|
@@ -1117,7 +1119,7 @@ class GlDriver extends Driver {
|
|
|
|
|
|
// Patch RGBA to be RGBA8 because texStorage expect a "Sized Internal Format"
|
|
|
var sizedFormat = tt.internalFmt == GL.RGBA ? GL.RGBA8 : tt.internalFmt;
|
|
|
- if( t.flags.has(IsArray) && !t.flags.has(Cube) ) {
|
|
|
+ if( ( t.flags.has(IsArray) || t.flags.has(Is3D) ) && !t.flags.has(Cube) ) {
|
|
|
gl.texStorage3D(bind, t.mipLevels, sizedFormat, tt.width, tt.height, t.layerCount);
|
|
|
checkError();
|
|
|
} else {
|
|
@@ -1128,6 +1130,7 @@ class GlDriver extends Driver {
|
|
|
for(mip in 0...t.mipLevels) {
|
|
|
var w = hxd.Math.imax(1, tt.width >> mip);
|
|
|
var h = hxd.Math.imax(1, tt.height >> mip);
|
|
|
+ var d = hxd.Math.imax(1, t.layerCount >> mip);
|
|
|
if( t.flags.has(Cube) ) {
|
|
|
for( i in 0...6 ) {
|
|
|
gl.texImage2D(CUBE_FACES[i], mip, tt.internalFmt, w, h, 0, getChannels(tt), tt.pixelFmt, null);
|
|
@@ -1136,6 +1139,9 @@ class GlDriver extends Driver {
|
|
|
} else if( t.flags.has(IsArray) ) {
|
|
|
gl.texImage3D(bind, mip, tt.internalFmt, w, h, t.layerCount, 0, getChannels(tt), tt.pixelFmt, null);
|
|
|
checkError();
|
|
|
+ } else if ( t.flags.has(Is3D) ) {
|
|
|
+ gl.texImage3D(bind, mip, tt.internalFmt, w, h, d, 0, getChannels(tt), tt.pixelFmt, null);
|
|
|
+ checkError();
|
|
|
} else {
|
|
|
gl.texImage2D(bind, mip, tt.internalFmt, w, h, 0, getChannels(tt), tt.pixelFmt, null);
|
|
|
checkError();
|
|
@@ -1272,11 +1278,11 @@ class GlDriver extends Driver {
|
|
|
}
|
|
|
|
|
|
override function uploadTextureBitmap( t : h3d.mat.Texture, bmp : hxd.BitmapData, mipLevel : Int, side : Int ) {
|
|
|
- #if hl
|
|
|
+ #if hl
|
|
|
var pixels = bmp.getPixels();
|
|
|
uploadTexturePixels(t, pixels, mipLevel, side);
|
|
|
pixels.dispose();
|
|
|
- #else
|
|
|
+ #else
|
|
|
if( t.format != RGBA || t.layerCount != 1 ) {
|
|
|
var pixels = bmp.getPixels();
|
|
|
uploadTexturePixels(t, pixels, mipLevel, side);
|
|
@@ -1287,7 +1293,7 @@ class GlDriver extends Driver {
|
|
|
gl.texSubImage2D(GL.TEXTURE_2D, mipLevel, 0, 0, getChannels(t.t), t.t.pixelFmt, img.getImageData(0, 0, bmp.width, bmp.height));
|
|
|
restoreBind();
|
|
|
}
|
|
|
- #end
|
|
|
+ #end
|
|
|
}
|
|
|
|
|
|
/*
|
|
@@ -1350,7 +1356,13 @@ class GlDriver extends Driver {
|
|
|
|
|
|
override function uploadTexturePixels( t : h3d.mat.Texture, pixels : hxd.Pixels, mipLevel : Int, side : Int ) {
|
|
|
var cubic = t.flags.has(Cube);
|
|
|
- var face = cubic ? CUBE_FACES[side] : t.flags.has(IsArray) ? GL.TEXTURE_2D_ARRAY : GL.TEXTURE_2D;
|
|
|
+ var face = GL.TEXTURE_2D;
|
|
|
+ if ( cubic )
|
|
|
+ face = CUBE_FACES[side];
|
|
|
+ if ( t.flags.has(IsArray) )
|
|
|
+ face = GL.TEXTURE_2D_ARRAY
|
|
|
+ else if ( t.flags.has(Is3D) )
|
|
|
+ face = GL.TEXTURE_3D;
|
|
|
var bind = getBindType(t);
|
|
|
gl.bindTexture(bind, t.t.t);
|
|
|
pixels.convert(t.format);
|
|
@@ -1358,14 +1370,14 @@ class GlDriver extends Driver {
|
|
|
#if hl
|
|
|
var stream = streamData(pixels.bytes.getData(),pixels.offset,dataLen);
|
|
|
if( t.format.match(S3TC(_)) ) {
|
|
|
- if( t.flags.has(IsArray) )
|
|
|
+ if( t.flags.has(IsArray) || t.flags.has(Is3D) )
|
|
|
#if (hlsdl >= version("1.12.0"))
|
|
|
gl.compressedTexSubImage3D(face, mipLevel, 0, 0, side, pixels.width, pixels.height, 1, t.t.internalFmt, dataLen, stream);
|
|
|
#else throw "TextureArray support requires hlsdl 1.12+"; #end
|
|
|
else
|
|
|
gl.compressedTexImage2D(face, mipLevel, t.t.internalFmt, pixels.width, pixels.height, 0, dataLen, stream);
|
|
|
} else {
|
|
|
- if( t.flags.has(IsArray) )
|
|
|
+ if( t.flags.has(IsArray) || t.flags.has(Is3D) )
|
|
|
#if (hlsdl >= version("1.12.0"))
|
|
|
gl.texSubImage3D(face, mipLevel, 0, 0, side, pixels.width, pixels.height, 1, getChannels(t.t), t.t.pixelFmt, stream);
|
|
|
#else throw "TextureArray support requires hlsdl 1.12+"; #end
|
|
@@ -1388,12 +1400,12 @@ class GlDriver extends Driver {
|
|
|
default: new Uint8Array(@:privateAccess pixels.bytes.b.buffer, pixels.offset, dataLen);
|
|
|
}
|
|
|
if( t.format.match(S3TC(_)) ) {
|
|
|
- if( t.flags.has(IsArray) )
|
|
|
+ if( t.flags.has(IsArray) || t.flags.has(Is3D) )
|
|
|
gl.compressedTexSubImage3D(face, mipLevel, 0, 0, side, pixels.width, pixels.height, 1, t.t.internalFmt, buffer);
|
|
|
else
|
|
|
gl.compressedTexSubImage2D(face, mipLevel, 0, 0, pixels.width, pixels.height, t.t.internalFmt, buffer);
|
|
|
} else {
|
|
|
- if( t.flags.has(IsArray) )
|
|
|
+ if( t.flags.has(IsArray) || t.flags.has(Is3D) )
|
|
|
gl.texSubImage3D(face, mipLevel, 0, 0, side, pixels.width, pixels.height, 1, getChannels(t.t), t.t.pixelFmt, buffer);
|
|
|
else
|
|
|
gl.texSubImage2D(face, mipLevel, 0, 0, pixels.width, pixels.height, getChannels(t.t), t.t.pixelFmt, buffer);
|