Skip to content
This repository has been archived by the owner on Aug 15, 2019. It is now read-only.

Temporarily revert aggressive uploading of packed textures. #1417

Merged
merged 1 commit into from
Nov 29, 2018
Merged
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
32 changes: 17 additions & 15 deletions src/kernels/backend_webgl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1803,29 +1803,31 @@ export class MathBackendWebGL implements KernelBackend {

let texData = this.texData.get(input.dataId);

if (texData.texture == null) {
if (texData.texture == null &&
!(!texData.isPacked && program.usesPackedTextures) &&
util.sizeFromShape(input.shape) <=
ENV.get('WEBGL_SIZE_UPLOAD_UNIFORM')) {
// Upload small tensors that live on the CPU as uniforms, not as
// textures. Do this only when the environment supports 32bit floats due
// to problems when comparing 16bit floats with 32bit floats.
// TODO(/~https://github.com/tensorflow/tfjs/issues/821): Make it possible
// for packed shaders to sample from uniforms.
if (!(!texData.isPacked && program.usesPackedTextures) &&
util.sizeFromShape(input.shape) <=
ENV.get('WEBGL_SIZE_UPLOAD_UNIFORM')) {
return {
shape: input.shape,
texData: null,
isUniform: true,
uniformValues: this.readSync(input.dataId) as TypedArray
};
}
return {
shape: input.shape,
texData: null,
isUniform: true,
uniformValues: this.readSync(input.dataId) as TypedArray
};

// TODO(annyuan): Revive this block once uploading to packed textures is
// fixed.

// This ensures that if a packed program's inputs have not yet been
// uploaded to the GPU, they get uploaded as packed right off the bat.
if (program.usesPackedTextures) {
texData.isPacked = true;
texData.shape = input.shape;
}
// if (program.usesPackedTextures) {
// texData.isPacked = true;
// texData.shape = input.shape;
//}
} else if (!!texData.isPacked !== !!program.usesPackedTextures) {
let preProcessProgram: UnpackProgram|PackProgram;
let processedInput: Tensor;
Expand Down