Skip to content
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
33 changes: 31 additions & 2 deletions sample/generateMipmap/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,49 @@
html, body {
margin: 0; /* remove default margin */
height: 100%; /* make body fill the browser window */
width: 100%;
display: flex;
place-content: center center;
}
canvas {
#container {
position: relative;
width: 600px;
height: 600px;
max-width: 100%;
display: block;
}
canvas, #grid {
width: 600px;
height: 600px;
max-width: 100%;
display: block;
}
#grid {
position: absolute;
left: 0;
top: 0;
display:grid;
grid-template-columns: 50% 50%;
grid-row: auto auto;
color: white;
}
#grid>* {
border: 1px solid black;
text-align: center;
}
</style>
<script defer src="main.js" type="module"></script>
<script defer type="module" src="../../js/iframe-helper.js"></script>
</head>
<body>
<canvas></canvas>
<div id="container">
<canvas></canvas>
<div id="grid">
<div>2d</div>
<div>2d-array</div>
<div>cube</div>
<div id="cube-array">cube-array</div>
</div>
</div>
</body>
</html>
11 changes: 9 additions & 2 deletions sample/generateMipmap/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const textures: {
});
putDataInTexture2dArray(device, texture);
generateMips(device, texture);
textures.push({ texture, viewDimension: '2d' });
textures.push({ texture, viewDimension: '2d-array' });
}

// Make a cube texture, put an image in each face, generate mips
Expand All @@ -93,7 +93,13 @@ const textures: {
}

// Compatibility mode might not support 'core-features-and-limits'
if (device.features.has('core-features-and-limits')) {
// Note: Checking for maxColorAttachments > 4 is not required by the spec
// but some browsers have not implemented 'core-features-and-limits'.
// We'll remove this once they do.
if (
device.features.has('core-features-and-limits') ||
device.limits.maxColorAttachments > 4
) {
// Make a cube array texture, put a different image in each layer, generate mips
const texture = device.createTexture({
size: [256, 256, 24],
Expand Down Expand Up @@ -122,6 +128,7 @@ if (device.features.has('core-features-and-limits')) {
putDataInTextureCubeFallback(device, texture);
generateMips(device, texture);
textures.push({ texture, viewDimension: 'cube' });
document.querySelector('#cube-array').textContent = 'cube(fallback)';
}

const module = device.createShaderModule({
Expand Down