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

Renamed BindBufferFormat to BindUniformBufferFormat #6222

Merged
merged 1 commit into from
Apr 3, 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 examples/src/examples/compute/texture-gen/example.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ assetListLoader.load(() => {
// format of a bind group, providing resources for the compute shader
computeBindGroupFormat: new pc.BindGroupFormat(device, [
// a uniform buffer we provided format for
new pc.BindBufferFormat(pc.UNIFORM_BUFFER_DEFAULT_SLOT_NAME, pc.SHADERSTAGE_COMPUTE),
new pc.BindUniformBufferFormat(pc.UNIFORM_BUFFER_DEFAULT_SLOT_NAME, pc.SHADERSTAGE_COMPUTE),
// input textures
new pc.BindTextureFormat('inTexture', pc.SHADERSTAGE_COMPUTE, undefined, undefined, false),
// output storage textures
Expand Down
2 changes: 1 addition & 1 deletion examples/src/examples/graphics/wgsl-shader/example.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const shaderDefinition = {
new pc.UniformFormat('amount', pc.UNIFORMTYPE_FLOAT)
]),
meshBindGroupFormat: new pc.BindGroupFormat(app.graphicsDevice, [
new pc.BindBufferFormat(pc.UNIFORM_BUFFER_DEFAULT_SLOT_NAME, pc.SHADERSTAGE_VERTEX | pc.SHADERSTAGE_FRAGMENT)
new pc.BindUniformBufferFormat(pc.UNIFORM_BUFFER_DEFAULT_SLOT_NAME, pc.SHADERSTAGE_VERTEX | pc.SHADERSTAGE_FRAGMENT)
])
};
const shader = new pc.Shader(app.graphicsDevice, shaderDefinition);
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export * from './platform/audio/constants.js';
// PLATFORM / GRAPHICS
export * from './platform/graphics/constants.js';
export { createGraphicsDevice } from './platform/graphics/graphics-device-create.js';
export { BindGroupFormat, BindBufferFormat, BindTextureFormat, BindStorageTextureFormat, BindStorageBufferFormat } from './platform/graphics/bind-group-format.js';
export { BindGroupFormat, BindUniformBufferFormat, BindTextureFormat, BindStorageTextureFormat, BindStorageBufferFormat } from './platform/graphics/bind-group-format.js';
export { BlendState } from './platform/graphics/blend-state.js';
export { Compute } from './platform/graphics/compute.js';
export { DepthState } from './platform/graphics/depth-state.js';
Expand Down
14 changes: 7 additions & 7 deletions src/platform/graphics/bind-group-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class BindBaseFormat {
/**
* @ignore
*/
class BindBufferFormat extends BindBaseFormat {
class BindUniformBufferFormat extends BindBaseFormat {
}

/**
Expand Down Expand Up @@ -83,8 +83,8 @@ class BindStorageTextureFormat extends BindBaseFormat {
* @ignore
*/
class BindGroupFormat {
/** @type {BindBufferFormat[]} */
bufferFormats = [];
/** @type {BindUniformBufferFormat[]} */
uniformBufferFormats = [];

/** @type {BindTextureFormat[]} */
textureFormats = [];
Expand Down Expand Up @@ -117,8 +117,8 @@ class BindGroupFormat {
}

// split the array into separate arrays
if (format instanceof BindBufferFormat) {
this.bufferFormats.push(format);
if (format instanceof BindUniformBufferFormat) {
this.uniformBufferFormats.push(format);
} else if (format instanceof BindTextureFormat) {
this.textureFormats.push(format);
} else if (format instanceof BindStorageTextureFormat) {
Expand All @@ -137,7 +137,7 @@ class BindGroupFormat {
// maps a buffer format name to an index
/** @type {Map<string, number>} */
this.bufferFormatsMap = new Map();
this.bufferFormats.forEach((bf, i) => this.bufferFormatsMap.set(bf.name, i));
this.uniformBufferFormats.forEach((bf, i) => this.bufferFormatsMap.set(bf.name, i));

// maps a texture format name to a slot index
/** @type {Map<string, number>} */
Expand Down Expand Up @@ -247,4 +247,4 @@ class BindGroupFormat {
}
}

export { BindBufferFormat, BindTextureFormat, BindGroupFormat, BindStorageTextureFormat, BindStorageBufferFormat };
export { BindUniformBufferFormat, BindTextureFormat, BindGroupFormat, BindStorageTextureFormat, BindStorageBufferFormat };
8 changes: 4 additions & 4 deletions src/platform/graphics/shader-processor.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
TYPE_FLOAT32, TYPE_INT8, TYPE_INT16, TYPE_INT32, TYPE_FLOAT16, SAMPLETYPE_INT, SAMPLETYPE_UINT
} from './constants.js';
import { UniformFormat, UniformBufferFormat } from './uniform-buffer-format.js';
import { BindGroupFormat, BindBufferFormat, BindTextureFormat } from './bind-group-format.js';
import { BindGroupFormat, BindUniformBufferFormat, BindTextureFormat } from './bind-group-format.js';

// accepted keywords
// TODO: 'out' keyword is not in the list, as handling it is more complicated due
Expand Down Expand Up @@ -270,10 +270,10 @@ class ShaderProcessor {
const meshUniformBufferFormat = meshUniforms.length ? new UniformBufferFormat(device, meshUniforms) : null;

// build mesh bind group format - start with uniform buffer
const bufferFormats = [];
const uniformBufferFormats = [];
if (meshUniformBufferFormat) {
// TODO: we could optimize visibility to only stages that use any of the data
bufferFormats.push(new BindBufferFormat(UNIFORM_BUFFER_DEFAULT_SLOT_NAME, SHADERSTAGE_VERTEX | SHADERSTAGE_FRAGMENT));
uniformBufferFormats.push(new BindUniformBufferFormat(UNIFORM_BUFFER_DEFAULT_SLOT_NAME, SHADERSTAGE_VERTEX | SHADERSTAGE_FRAGMENT));
}

// add textures uniforms
Expand Down Expand Up @@ -307,7 +307,7 @@ class ShaderProcessor {
// validate types in else

});
const meshBindGroupFormat = new BindGroupFormat(device, [...bufferFormats, ...textureFormats]);
const meshBindGroupFormat = new BindGroupFormat(device, [...uniformBufferFormats, ...textureFormats]);

// generate code for uniform buffers
let code = '';
Expand Down
2 changes: 1 addition & 1 deletion src/platform/graphics/webgpu/webgpu-bind-group-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class WebgpuBindGroupFormat {
let key = '';

// buffers
bindGroupFormat.bufferFormats.forEach((bufferFormat) => {
bindGroupFormat.uniformBufferFormats.forEach((bufferFormat) => {

const visibility = WebgpuUtils.shaderStage(bufferFormat.visibility);
key += `#${bufferFormat.slot}U:${visibility}`;
Expand Down
2 changes: 1 addition & 1 deletion src/platform/graphics/webgpu/webgpu-bind-group.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class WebgpuBindGroup {
});

// uniform buffers
const uniformBufferFormats = bindGroup.format.bufferFormats;
const uniformBufferFormats = bindGroup.format.uniformBufferFormats;
bindGroup.uniformBuffers.forEach((ub, i) => {
const slot = uniformBufferFormats[i].slot;
const buffer = ub.persistent ? ub.impl.buffer : ub.allocation.gpuBuffer.buffer;
Expand Down
4 changes: 2 additions & 2 deletions src/platform/graphics/webgpu/webgpu-clear-renderer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Debug, DebugHelper } from "../../../core/debug.js";
import { BindBufferFormat, BindGroupFormat } from "../bind-group-format.js";
import { BindUniformBufferFormat, BindGroupFormat } from "../bind-group-format.js";
import { UniformBufferFormat, UniformFormat } from "../uniform-buffer-format.js";
import { BlendState } from "../blend-state.js";
import {
Expand Down Expand Up @@ -79,7 +79,7 @@ class WebgpuClearRenderer {

// format of the bind group
const bindGroupFormat = new BindGroupFormat(device, [
new BindBufferFormat(UNIFORM_BUFFER_DEFAULT_SLOT_NAME, SHADERSTAGE_VERTEX | SHADERSTAGE_FRAGMENT)
new BindUniformBufferFormat(UNIFORM_BUFFER_DEFAULT_SLOT_NAME, SHADERSTAGE_VERTEX | SHADERSTAGE_FRAGMENT)
]);

// bind group
Expand Down
4 changes: 2 additions & 2 deletions src/scene/renderer/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { DebugGraphics } from '../../platform/graphics/debug-graphics.js';
import { UniformBuffer } from '../../platform/graphics/uniform-buffer.js';
import { BindGroup } from '../../platform/graphics/bind-group.js';
import { UniformFormat, UniformBufferFormat } from '../../platform/graphics/uniform-buffer-format.js';
import { BindGroupFormat, BindBufferFormat, BindTextureFormat } from '../../platform/graphics/bind-group-format.js';
import { BindGroupFormat, BindUniformBufferFormat, BindTextureFormat } from '../../platform/graphics/bind-group-format.js';

import { ShadowMapCache } from './shadow-map-cache.js';
import { ShadowRendererLocal } from './shadow-renderer-local.js';
Expand Down Expand Up @@ -818,7 +818,7 @@ class Renderer {
const formats = [

// uniform buffer needs to be first, as the shader processor assumes slot 0 for it
new BindBufferFormat(UNIFORM_BUFFER_DEFAULT_SLOT_NAME, SHADERSTAGE_VERTEX | SHADERSTAGE_FRAGMENT),
new BindUniformBufferFormat(UNIFORM_BUFFER_DEFAULT_SLOT_NAME, SHADERSTAGE_VERTEX | SHADERSTAGE_FRAGMENT),

new BindTextureFormat('lightsTextureFloat', SHADERSTAGE_FRAGMENT, TEXTUREDIMENSION_2D, SAMPLETYPE_UNFILTERABLE_FLOAT),
new BindTextureFormat('lightsTexture8', SHADERSTAGE_FRAGMENT, TEXTUREDIMENSION_2D, SAMPLETYPE_UNFILTERABLE_FLOAT),
Expand Down
4 changes: 2 additions & 2 deletions src/scene/renderer/shadow-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { shaderChunks } from '../shader-lib/chunks/chunks.js';
import { createShaderFromCode } from '../shader-lib/utils.js';
import { LightCamera } from './light-camera.js';
import { UniformBufferFormat, UniformFormat } from '../../platform/graphics/uniform-buffer-format.js';
import { BindBufferFormat, BindGroupFormat } from '../../platform/graphics/bind-group-format.js';
import { BindUniformBufferFormat, BindGroupFormat } from '../../platform/graphics/bind-group-format.js';
import { BlendState } from '../../platform/graphics/blend-state.js';

function gauss(x, sigma) {
Expand Down Expand Up @@ -579,7 +579,7 @@ class ShadowRenderer {

// format of the view bind group - contains single uniform buffer, and no textures
this.viewBindGroupFormat = new BindGroupFormat(this.device, [
new BindBufferFormat(UNIFORM_BUFFER_DEFAULT_SLOT_NAME, SHADERSTAGE_VERTEX | SHADERSTAGE_FRAGMENT)
new BindUniformBufferFormat(UNIFORM_BUFFER_DEFAULT_SLOT_NAME, SHADERSTAGE_VERTEX | SHADERSTAGE_FRAGMENT)
]);
}
}
Expand Down