Skip to content

Commit

Permalink
Remove TexelDataRepresentationImpl.isGPULittleEndian (gpuweb#357)
Browse files Browse the repository at this point in the history
  • Loading branch information
austinEng authored Nov 18, 2020
1 parent e0b76d2 commit 12581ea
Showing 1 changed file with 9 additions and 20 deletions.
29 changes: 9 additions & 20 deletions src/webgpu/util/texture/texelData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,6 @@ export interface TexelDataRepresentation {
}

class TexelDataRepresentationImpl implements TexelDataRepresentation {
// TODO: Determine endianness of the GPU data?
private isGPULittleEndian = true;

constructor(
private readonly format: UncompressedTextureFormat,
readonly componentOrder: TexelComponent[],
Expand Down Expand Up @@ -257,7 +254,7 @@ class TexelDataRepresentationImpl implements TexelDataRepresentation {
assert(byteOffset === bitOffset / 8 && byteLength === bitLength / 8);
switch (byteLength) {
case 4:
new DataView(data, byteOffset, byteLength).setFloat32(0, value, this.isGPULittleEndian);
new DataView(data, byteOffset, byteLength).setFloat32(0, value, true);
break;
default:
unreachable();
Expand All @@ -273,10 +270,10 @@ class TexelDataRepresentationImpl implements TexelDataRepresentation {
new DataView(data, byteOffset, byteLength).setInt8(0, value);
break;
case 2:
new DataView(data, byteOffset, byteLength).setInt16(0, value, this.isGPULittleEndian);
new DataView(data, byteOffset, byteLength).setInt16(0, value, true);
break;
case 4:
new DataView(data, byteOffset, byteLength).setInt32(0, value, this.isGPULittleEndian);
new DataView(data, byteOffset, byteLength).setInt32(0, value, true);
break;
default:
unreachable();
Expand All @@ -292,18 +289,10 @@ class TexelDataRepresentationImpl implements TexelDataRepresentation {
new DataView(data, byteOffset, byteLength).setUint8(0, value);
break;
case 2:
new DataView(data, byteOffset, byteLength).setUint16(
0,
value,
this.isGPULittleEndian
);
new DataView(data, byteOffset, byteLength).setUint16(0, value, true);
break;
case 4:
new DataView(data, byteOffset, byteLength).setUint32(
0,
value,
this.isGPULittleEndian
);
new DataView(data, byteOffset, byteLength).setUint32(0, value, true);
break;
default:
unreachable();
Expand All @@ -314,7 +303,7 @@ class TexelDataRepresentationImpl implements TexelDataRepresentation {
switch (this.totalBitLength()) {
case 32: {
const view = new DataView(data);
const currentValue = view.getUint32(0, this.isGPULittleEndian);
const currentValue = view.getUint32(0, true);

let mask = 0xffffffff;
const bitsToClearRight = bitOffset;
Expand All @@ -325,7 +314,7 @@ class TexelDataRepresentationImpl implements TexelDataRepresentation {

const newValue = (currentValue & ~mask) | (value << bitOffset);

view.setUint32(0, newValue, this.isGPULittleEndian);
view.setUint32(0, newValue, true);
break;
}
default:
Expand Down Expand Up @@ -418,7 +407,7 @@ class TexelDataRepresentationImpl implements TexelDataRepresentation {
new DataView(buf).setUint32(
0,
encodeRGB9E5UFloat(components.R, components.G, components.B),
this.isGPULittleEndian
true
);
return buf;
}
Expand Down Expand Up @@ -450,7 +439,7 @@ class TexelDataRepresentationImpl implements TexelDataRepresentation {
new DataView(buf).setUint32(
0,
encodeRGB9E5UFloat(components.R, components.G, components.B),
this.isGPULittleEndian
true
);
return buf;
}
Expand Down

0 comments on commit 12581ea

Please sign in to comment.