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

[pull] main from gpuweb:main #73

Merged
merged 2 commits into from
Jan 16, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ function writeOpNeedsStorageTexture({ op, in: context }: { op: Op; in: Operation
);
}

function getVisibilityForContext(context: OperationContext) {
return context === 'render-bundle-encoder' || context === 'render-pass-encoder'
? GPUShaderStage.FRAGMENT
: GPUShaderStage.COMPUTE;
}

class TextureSyncTestHelper extends OperationContextHelper {
private texture: GPUTexture;

Expand Down Expand Up @@ -169,19 +175,19 @@ class TextureSyncTestHelper extends OperationContextHelper {
format: this.kTextureFormat,
usage: GPUTextureUsage.COPY_SRC | GPUTextureUsage.STORAGE_BINDING,
});

const visibility = getVisibilityForContext(context);
const bindGroupLayout = this.device.createBindGroupLayout({
entries: [
{
binding: 0,
visibility: GPUShaderStage.FRAGMENT | GPUShaderStage.COMPUTE,
visibility,
texture: {
sampleType: 'unfilterable-float',
},
},
{
binding: 1,
visibility: GPUShaderStage.FRAGMENT | GPUShaderStage.COMPUTE,
visibility,
storageTexture: {
access: 'write-only',
format: this.kTextureFormat,
Expand Down Expand Up @@ -440,11 +446,12 @@ class TextureSyncTestHelper extends OperationContextHelper {
break;
}
case 'storage': {
const visibility = getVisibilityForContext(context);
const bindGroupLayout = this.device.createBindGroupLayout({
entries: [
{
binding: 0,
visibility: GPUShaderStage.FRAGMENT | GPUShaderStage.COMPUTE,
visibility,
storageTexture: {
access: 'write-only',
format: this.kTextureFormat,
Expand Down
13 changes: 10 additions & 3 deletions src/webgpu/web_platform/canvas/configure.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import {
filterFormatsByFeature,
viewCompatible,
} from '../../format_info.js';
import { GPUTest } from '../../gpu_test.js';
import { GPUTest, MaxLimitsTestMixin } from '../../gpu_test.js';
import { kAllCanvasTypes, createCanvas } from '../../util/create_elements.js';

export const g = makeTestGroup(GPUTest);
export const g = makeTestGroup(MaxLimitsTestMixin(GPUTest));

g.test('defaults')
.desc(
Expand Down Expand Up @@ -212,6 +212,7 @@ g.test('usage')
)
.fn(t => {
const { canvasType, usage } = t.params;

const canvas = createCanvas(t, canvasType, 2, 2);
const ctx = canvas.getContext('webgpu');
assert(ctx instanceof GPUCanvasContext, 'Failed to get WebGPU context from canvas');
Expand Down Expand Up @@ -269,7 +270,13 @@ g.test('usage')
});
}

if (usage & GPUConst.TextureUsage.STORAGE_BINDING) {
const canUseStorageTextureInFragmentShader =
!t.isCompatibility || t.device.limits.maxStorageTexturesInFragmentStage! > 0;

if (
(usage & GPUConst.TextureUsage.STORAGE_BINDING) !== 0 &&
canUseStorageTextureInFragmentShader
) {
const bgl = t.device.createBindGroupLayout({
entries: [
{
Expand Down
Loading