Skip to content
Open
Show file tree
Hide file tree
Changes from 55 commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
0f5ecf6
WIP: Basis support
lbergman Oct 31, 2019
e6f75d9
Add all compressed texture formats to isSupportedFormat
lbergman Oct 31, 2019
c8b85c4
Remove unused pattern for supported format
lbergman Oct 31, 2019
1f50d20
Make BasisTextureLoader js only
lbergman Oct 31, 2019
599adb5
Add bsis support
lbergman Nov 18, 2019
0d4b759
Get image width/height from basis bytes
lbergman Nov 18, 2019
d3fc2f7
Throw when basis texture on non-js target
lbergman Nov 18, 2019
3bb8c54
Cleanup basis width detection
lbergman Nov 20, 2019
49d6a2d
Remove duplicate compressed texture detection
lbergman Nov 20, 2019
7779b53
Use stride 1 with ETC and PBRTC
lbergman Nov 20, 2019
42fa2b7
Prioritize ETC textures last
lbergman Nov 20, 2019
1c6f8ed
Remove unused import
lbergman Nov 20, 2019
e8067c3
Support non alpha PVRTC
lbergman Nov 20, 2019
4c91180
Merge pull request #4 from HacksawStudios/basis_support
lbergman Mar 9, 2020
eb65cd6
chore: Add util files
lbergman Mar 25, 2020
1ee5cd1
Merge remote-tracking branch 'upstream/master'
lbergman Mar 25, 2020
6cdee26
fix: Flickering due to incorrect timing of clear https://github.com/…
lbergman Mar 25, 2020
3a00b7f
Merge pull request #5 from HacksawStudios/clear_background_fix
lbergman Mar 25, 2020
b83bdbd
Merge pull request #6 from HacksawStudios/engine_clear_fix
lbergman Mar 25, 2020
34c18e4
fix; Making separate alpha handling configurable in h2d.RenderContex…
lbergman Apr 6, 2020
3c9b5b8
Merge pull request #7 from HacksawStudios/separate_alpha_handling_in_…
lbergman Apr 6, 2020
08597ae
Enable high precision shaders if supported
lbergman Apr 21, 2020
4784fd2
Merge pull request #8 from HacksawStudios/enable_highp_when_available
lbergman Apr 21, 2020
0d61641
chore: Merge latest heaps master
lbergman Aug 17, 2020
b1a1bd4
Merge pull request #9 from HacksawStudios/update_from_master
lbergman Aug 17, 2020
7ee2110
chore: Update package version
lbergman Aug 17, 2020
3f6dc7e
Merge branch 'master' of https://github.com/HacksawStudios/heaps
lbergman Aug 17, 2020
713cad9
Merge remote-tracking branch 'upstream/master' into update_from_upstream
lbergman Mar 2, 2021
438e64c
fix: Merge issues
lbergman Mar 2, 2021
9e4a14a
feat: Add 'addTangent' to HMDModel
lbergman Mar 2, 2021
702b50d
fix: Formatting
lbergman Mar 2, 2021
75d0407
Merge pull request #10 from HacksawStudios/update_from_upstream
lbergman Mar 2, 2021
7baf553
chore: Update version
lbergman Mar 2, 2021
ae4a753
Merge remote-tracking branch 'upstream/master' into update_from_upstream
tkwiatek Nov 22, 2022
ae0329a
Merge pull request #11 from HacksawStudios/update_from_upstream
tkwiatek Nov 23, 2022
a652075
chore: Add Basis condition to fix compilation issue
tkwiatek Nov 23, 2022
5865e61
Merge pull request #12 from HacksawStudios/add_missing_condition_to_i…
lbergman Nov 23, 2022
8ac0833
Merge branch 'HeapsIO:master' into master
lbergman Feb 16, 2023
e1c9372
Revert unnecessary changes
lbergman Feb 16, 2023
258ad00
chore: Remove unneccessary changes
lbergman Feb 17, 2023
42ca30e
chore: Update npmrc
lbergman Feb 17, 2023
b10ed37
fix: Add missing brace
lbergman Feb 17, 2023
53ed8cf
style: Use correct indenting
lbergman Feb 17, 2023
479ad86
style: Add ending linebreak
lbergman Feb 17, 2023
91c1d68
style: Remove unnecessary whitespace changes
lbergman Feb 17, 2023
4929a10
fix: Add missing return definitions for hxsl setParamIndexValue and s…
lbergman Feb 17, 2023
f116fe8
Merge pull request #14 from HacksawStudios/fix_merge
tkwiatek Feb 20, 2023
b099063
chore: Update version
lbergman Feb 20, 2023
433ebca
chore: Update version
lbergman Feb 20, 2023
dff1eba
chore: Set haxe-module-installer as dev dependency
lbergman Feb 20, 2023
4e10301
chore: Exectute toString function on transcoder bytes
tkwiatek May 12, 2023
306a104
chore: Fix haxe 4.3.1 warnings
tkwiatek May 19, 2023
b7f9c71
Merge pull request #15 from HacksawStudios/haxe_4.3.1_compability
lbergman May 25, 2023
a7956d2
chore: Update version
lbergman May 25, 2023
e9e43e6
Merge branch 'master' of https://github.com/HacksawStudios/heaps
Jan 17, 2024
048826f
Merge pull request #16 from Vekzzor/master
lbergman Feb 6, 2024
9c21164
Adding metadata for SDF
Aug 30, 2024
ce4cdb5
fix: Restore use of initSize
Aug 30, 2024
9f95949
Merge pull request #17 from HacksawStudios/addSdfFontMetadata2
lbergman Aug 30, 2024
0563d7e
chore: Update package version
lbergman Sep 2, 2024
7f0c8b4
Merge changes from upstream
lbergman Nov 14, 2024
cf4437f
Merge pull request #19 from HacksawStudios/update_from_upstream
lbergman Nov 14, 2024
77a5ba8
chore: Merge from master
lbergman Nov 14, 2024
eb8edff
feat: WIP ktx2 support
lbergman Nov 27, 2024
a986e7d
style: Fix formatting
lbergman Nov 28, 2024
de46321
chore: Merge master
lbergman Nov 28, 2024
2d7156b
chore: Update BasisTextureLoader to support ktx2 for testing (should …
lbergman Nov 28, 2024
e25fa5c
chore: WIP ktx2 support
lbergman Dec 4, 2024
a3e6d3a
feat: Remove support for PVRTC textures
lbergman Dec 27, 2024
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: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ bin
/hxd/net/inspect.min.css
/hxd/inspect/inspect.min.css
/samples/build
/node_modules
/*.xml
.vscode
/tools/mikktspace/out
*.exe
.history
7 changes: 7 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
.gitlab-ci.yml
.idea
*.iml
bin
.history
.haxelib
3 changes: 3 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
registry=https://hacksawgaming-281033247142.d.codeartifact.eu-west-1.amazonaws.com/npm/hacksaw-client-artifacts/
//hacksawgaming-281033247142.d.codeartifact.eu-west-1.amazonaws.com/npm/hacksaw-client-artifacts/:always-auth=true
//hacksawgaming-281033247142.d.codeartifact.eu-west-1.amazonaws.com/npm/hacksaw-client-artifacts/:_authToken=${CODEARTIFACT_AUTH_TOKEN}
5 changes: 3 additions & 2 deletions h3d/Engine.hx
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ class Engine {
if( !driver.isDisposed() ) driver.resize(width, height);
}

public function begin() {
public function begin(preventClear = false) {
if( driver.isDisposed() )
return false;
// init
Expand All @@ -292,7 +292,8 @@ class Engine {
haxe.System.beginFrame();
#end
driver.begin(hxd.Timer.frameCount);
if( backgroundColor != null ) clear(backgroundColor, 1, 0);
if( backgroundColor != null && !preventClear )
clear(backgroundColor, 1, 0);
return true;
}

Expand Down
114 changes: 93 additions & 21 deletions h3d/impl/GlDriver.hx
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package h3d.impl;
import h3d.impl.Driver;
import h3d.mat.Data;
import h3d.mat.Pass;
import h3d.mat.Stencil;
import h3d.mat.Data;

#if (js||hlsdl||usegl)

#if js
import hxd.impl.TypedArray;
import js.html.webgl.RenderingContext;

private typedef GL = js.html.webgl.GL2;
private typedef Uniform = js.html.webgl.UniformLocation;
private typedef Program = js.html.webgl.Program;
Expand Down Expand Up @@ -87,6 +89,9 @@ class GlDriver extends Driver {
static var UID = 0;
public var gl : GL;
public static var ALLOW_WEBGL2 = true;
// Set to 'mediump' to avoid high precision. Can give better performance, but will can mess up shadows for example.
public static var MAX_PRECISION = 'highp';
public var textureSupport:hxd.PixelFormat;
#end

#if (hlsdl||usegl)
Expand Down Expand Up @@ -893,7 +898,10 @@ class GlDriver extends Driver {
case GL.RED, GL.R8, GL.R16F, GL.R32F, 0x822A: GL.RED;
case GL.RG, GL.RG8, GL.RG16F, GL.RG32F, 0x822C: GL.RG;
case GL.RGB16F, GL.RGB32F, 0x8054, 0x8E8F: GL.RGB;
case 0x83F1, 0x83F2, 0x83F3, 0x805B, 0x8E8C: GL.RGBA;
case hxd.PixelFormat.DXT_FORMAT.RGBA_DXT1,hxd.PixelFormat.DXT_FORMAT.RGBA_DXT3,
hxd.PixelFormat.DXT_FORMAT.RGBA_DXT5,hxd.PixelFormat.ASTC_FORMAT.RGBA_4x4,
hxd.PixelFormat.PVRTC_FORMAT.RGBA_4BPPV1, 0x805B, 0x8E8C : GL.RGBA;
case hxd.PixelFormat.PVRTC_FORMAT.RGB_4BPPV1, hxd.PixelFormat.ETC_FORMAT.RGB_ETC1: GL.RGB;
default: throw "Invalid format " + t.internalFmt;
}
}
Expand All @@ -905,6 +913,7 @@ class GlDriver extends Driver {
case SRGB, SRGB_ALPHA: hasFeature(SRGBTextures);
case R8, RG8, RGB8, R16F, RG16F, RGB16F, R32F, RG32F, RGB32F, RG11B10UF, RGB10A2: #if js glES >= 3 #else true #end;
case S3TC(n): n <= maxCompressedTexturesSupport;
case ASTC(_), ETC(_), PVRTC(_): #if js true #else false #end;
default: false;
}
}
Expand Down Expand Up @@ -980,16 +989,34 @@ class GlDriver extends Driver {
tt.internalFmt = GL.R11F_G11F_B10F;
tt.pixelFmt = GL.UNSIGNED_INT_10F_11F_11F_REV;
case S3TC(n) if( n <= maxCompressedTexturesSupport ):
if( t.width&3 != 0 || t.height&3 != 0 )
throw "Compressed texture "+t+" has size "+t.width+"x"+t.height+" - must be a multiple of 4";
checkMult4(t);
switch( n ) {
case 1: tt.internalFmt = 0x83F1; // COMPRESSED_RGBA_S3TC_DXT1_EXT
case 2: tt.internalFmt = 0x83F2; // COMPRESSED_RGBA_S3TC_DXT3_EXT
case 3: tt.internalFmt = 0x83F3; // COMPRESSED_RGBA_S3TC_DXT5_EXT
case 1: tt.internalFmt = hxd.PixelFormat.DXT_FORMAT.RGBA_DXT1;
case 2: tt.internalFmt = hxd.PixelFormat.DXT_FORMAT.RGBA_DXT3;
case 3: tt.internalFmt = hxd.PixelFormat.DXT_FORMAT.RGBA_DXT5;
case 6: tt.internalFmt = 0x8E8F; // COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT
case 7: tt.internalFmt = 0x8E8C; // COMPRESSED_RGBA_BPTC_UNORM
default: throw "Unsupported texture format "+t.format;
}
case ASTC(n):
checkMult4(t);
switch( n ) {
case 10: tt.internalFmt = hxd.PixelFormat.ASTC_FORMAT.RGBA_4x4;
default: throw "Unsupported texture format "+t.format;
}
case ETC(n):
checkMult4(t);
switch( n ) {
case 0: tt.internalFmt = hxd.PixelFormat.ETC_FORMAT.RGB_ETC1;
default: throw "Unsupported texture format "+t.format;
}
case PVRTC(n):
checkMult4(t);
switch(n) {
case 8: tt.internalFmt = hxd.PixelFormat.PVRTC_FORMAT.RGB_4BPPV1;
case 9: tt.internalFmt = hxd.PixelFormat.PVRTC_FORMAT.RGBA_4BPPV1;
default: throw "Unsupported texture format "+t.format;
}
default:
throw "Unsupported texture format "+t.format;
}
Expand Down Expand Up @@ -1046,6 +1073,9 @@ class GlDriver extends Driver {
gl.texImage3D(bind, mip, tt.internalFmt, w, h, t.layerCount, 0, getChannels(tt), tt.pixelFmt, null);
checkError();
} else {
#if js
if( !t.format.match(S3TC(_)) && !t.format.match(ETC(_)) && !t.format.match(ASTC(_)) && !t.format.match(PVRTC(_)))
#end
gl.texImage2D(bind, mip, tt.internalFmt, w, h, 0, getChannels(tt), tt.pixelFmt, null);
checkError();
}
Expand All @@ -1062,6 +1092,11 @@ class GlDriver extends Driver {
return tt;
}

inline function checkMult4(t:h3d.mat.Texture) {
if( t.width&3 != 0 || t.height&3 != 0 )
throw "Compressed texture "+t+" has size "+t.width+"x"+t.height+" - must be a multiple of 4";
}

function restoreBind() {
var t = boundTextures[lastActiveIndex];
if( t == null )
Expand Down Expand Up @@ -1294,16 +1329,17 @@ class GlDriver extends Driver {
case RGB10A2, RG11B10UF: new Uint32Array(@:privateAccess pixels.bytes.b.buffer, pixels.offset, dataLen>>2);
default: new Uint8Array(@:privateAccess pixels.bytes.b.buffer, pixels.offset, dataLen);
}
if( t.format.match(S3TC(_)) ) {
if( t.flags.has(IsArray) )
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) )
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);
switch (t.format) {
case S3TC(_), ASTC(_), PVRTC(_), ETC(_):
if( t.flags.has(IsArray) )
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);
default:
if( t.flags.has(IsArray) )
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);
}
#else
throw "Not implemented";
Expand Down Expand Up @@ -1749,15 +1785,51 @@ class GlDriver extends Driver {
}

#if js
/**
Get the max supported precision to use for shaders
Limited by MAX_PRECISION value.
**/
public function getMaxPrecision() {
if ( gl.getShaderPrecisionFormat( RenderingContext.VERTEX_SHADER, RenderingContext.HIGH_FLOAT ).precision > 0 &&
gl.getShaderPrecisionFormat( RenderingContext.FRAGMENT_SHADER, RenderingContext.HIGH_FLOAT ).precision > 0 ) {
return MAX_PRECISION;
}
return 'mediump';
}

public function checkTextureSupport():hxd.PixelFormat {
var astcSupported = gl.getExtension('WEBGL_compressed_texture_astc') != null;
var dxtSupported = gl.getExtension('WEBGL_compressed_texture_s3tc') != null;
var pvrtcSupported = gl.getExtension('WEBGL_compressed_texture_pvrtc') != null
|| gl.getExtension('WEBKIT_WEBGL_compressed_texture_pvrtc') != null;
var etcSupported = gl.getExtension('WEBGL_compressed_texture_etc1') != null;
return if(astcSupported) {
hxd.PixelFormat.ASTC();
} else if(dxtSupported){
hxd.PixelFormat.S3TC();
} else if(pvrtcSupported){
hxd.PixelFormat.PVRTC();
} else if(etcSupported){
hxd.PixelFormat.ETC();
} else {
null;
}
}
var features : Map<Feature,Bool> = new Map();
var has16Bits : Bool;
function makeFeatures() {
for( f in Type.allEnums(Feature) )
features.set(f,checkFeature(f));
if( gl.getExtension("WEBGL_compressed_texture_s3tc") != null ) {
maxCompressedTexturesSupport = 3;
if( gl.getExtension("EXT_texture_compression_bptc") != null )
maxCompressedTexturesSupport = 7;
textureSupport = checkTextureSupport();
maxCompressedTexturesSupport = switch (textureSupport) {
case hxd.PixelFormat.ASTC(_), hxd.PixelFormat.ETC(_), hxd.PixelFormat.PVRTC(_): 3;
case hxd.PixelFormat.S3TC(_) :
if( gl.getExtension("EXT_texture_compression_bptc") != null ) {
7;
} else {
3;
}
default: 0;
}
if( glES < 3 )
gl.getExtension("WEBGL_depth_texture");
Expand Down
20 changes: 12 additions & 8 deletions haxelib.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
{
"name" : "heaps",
"url" : "http://heaps.io",
"license" : "BSD",
"description" : "The GPU Game Framework",
"version" : "2.0.0",
"releasenote" : "See CHANGELOG.md",
"contributors" : ["ncannasse"],
"dependencies" : { "format" : "" }
"name": "heaps",
"url": "http://heaps.io",
"license": "BSD",
"description": "The GPU Game Framework",
"version": "2.0.0",
"releasenote": "See CHANGELOG.md",
"contributors": [
"ncannasse"
],
"dependencies": {
"format": ""
}
}
24 changes: 23 additions & 1 deletion hxd/PixelFormat.hx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,30 @@ enum PixelFormat {
RG16U;
RGB16U;
RGBA16U;
S3TC( v : Int );
PVRTC( ?v : Int);
ASTC( ?v : Int );
ETC( ?v : Int );
S3TC( ?v : Int );
Depth16;
Depth24;
Depth24Stencil8;
}

enum abstract ASTC_FORMAT(Int) from Int to Int {
final RGBA_4x4 = 0x93B0;
}

enum abstract DXT_FORMAT(Int) from Int to Int {
final RGBA_DXT1 = 0x83F1;
final RGBA_DXT3 = 0x83F2;
final RGBA_DXT5 = 0x83F3;
}

enum abstract ETC_FORMAT(Int) from Int to Int {
final RGB_ETC1 = 0x8D64;
}

enum abstract PVRTC_FORMAT(Int) from Int to Int {
final RGB_4BPPV1 = 0x8C00;
final RGBA_4BPPV1 = 0x8C02;
}
6 changes: 5 additions & 1 deletion hxd/Pixels.hx
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,9 @@ class Pixels {
this.bytes = nbytes;

case [S3TC(a),S3TC(b)] if( a == b ):
case [ASTC(a),ASTC(b)] if( a == b ):
case [ETC(a),ETC(b)] if( a == b ):
case [PVRTC(a),PVRTC(b)] if( a == b ):
// nothing

#if (hl && hl_ver >= "1.10")
Expand Down Expand Up @@ -559,6 +562,7 @@ class Pixels {
case RGB32F: 12;
case RGB10A2: 4;
case RG11B10UF: 4;
case ASTC(n), ETC(n), PVRTC(n): 1;
case S3TC(n):
var blocks = (width + 3) >> 2;
if( n == 1 || n == 4 )
Expand Down Expand Up @@ -604,7 +608,7 @@ class Pixels {
channel.toInt() * 4;
case RGB10A2, RG11B10UF:
throw "Bit packed format";
case S3TC(_), Depth16, Depth24, Depth24Stencil8:
case S3TC(_), ASTC(_), ETC(_), PVRTC(_), Depth16, Depth24, Depth24Stencil8:
throw "Not supported";
}
}
Expand Down
4 changes: 2 additions & 2 deletions hxd/net/BinaryLoader.hx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class BinaryLoader {
throw msg;
}

public function load() {
public function load(raw = false) {
#if js

var xhr = new js.html.XMLHttpRequest();
Expand All @@ -32,7 +32,7 @@ class BinaryLoader {
onError(xhr.statusText);
return;
}
onLoaded(haxe.io.Bytes.ofData(xhr.response));
onLoaded(raw ? xhr.response : haxe.io.Bytes.ofData(xhr.response));
}

xhr.onprogress = function(e) {
Expand Down
Loading