Diff
checker
Texte
Texte
Images
Documents
Excel
Dossiers
Legal
Enterprise
Application de bureau
Prix
Se connecter
Télécharger Diffchecker Desktop
Comparer le texte
Trouver la différence entre deux fichiers texte
Outils
Historique
Éditeur live
Cacher identiques
Sans retour à la ligne
Vue
Divisé
Unifié
Niveau de précision
Intelligent
Mot
Caractère
Coloration syntaxique
Choisir la syntaxe
Ignorer
Transformer le texte
Aller au premier écart
Modifier l'entrée
Diffchecker Desktop
La façon la plus sécurisée d'utiliser Diffchecker. Obtenez l'application Diffchecker Desktop : vos diffs ne quittent jamais votre ordinateur !
Obtenir Desktop
Untitled diff
Créé
il y a 2 ans
Le diff n'expire jamais
Effacer
Exporter
Partager
Expliquer
5 suppressions
Lignes
Total
Supprimé
Caractères
Total
Supprimé
Pour continuer à utiliser cette fonctionnalité, passez à
Diff
checker
Pro
Voir les prix
151 lignes
Copier tout
10 ajouts
Lignes
Total
Ajouté
Caractères
Total
Ajouté
Pour continuer à utiliser cette fonctionnalité, passez à
Diff
checker
Pro
Voir les prix
153 lignes
Copier tout
import { makeSample, SampleInit } from '../../components/SampleLayout';
import { makeSample, SampleInit } from '../../components/SampleLayout';
import fullscreenTexturedQuadWGSL from '../../shaders/fullscreenTexturedQuad.wgsl';
import fullscreenTexturedQuadWGSL from '../../shaders/fullscreenTexturedQuad.wgsl';
import sampleExternalTextureWGSL from '../../shaders/sampleExternalTexture.frag.wgsl';
import sampleExternalTextureWGSL from '../../shaders/sampleExternalTexture.frag.wgsl';
const init: SampleInit = async ({ canvas, pageState, gui }) => {
const init: SampleInit = async ({ canvas, pageState, gui }) => {
// Set video element
// Set video element
const video = document.createElement('video');
const video = document.createElement('video');
video.loop = true;
video.loop = true;
video.autoplay = true;
video.autoplay = true;
video.muted = true;
video.muted = true;
video.src = '../assets/video/pano.webm';
video.src = '../assets/video/pano.webm';
await video.play();
await video.play();
const adapter = await navigator.gpu.requestAdapter();
const adapter = await navigator.gpu.requestAdapter();
const device = await adapter.requestDevice();
const device = await adapter.requestDevice();
if (!pageState.active) return;
if (!pageState.active) return;
const context = canvas.getContext('webgpu') as GPUCanvasContext;
const context = canvas.getContext('webgpu') as GPUCanvasContext;
const devicePixelRatio = window.devicePixelRatio;
const devicePixelRatio = window.devicePixelRatio;
canvas.width = canvas.clientWidth * devicePixelRatio;
canvas.width = canvas.clientWidth * devicePixelRatio;
canvas.height = canvas.clientHeight * devicePixelRatio;
canvas.height = canvas.clientHeight * devicePixelRatio;
const presentationFormat = navigator.gpu.getPreferredCanvasFormat();
const presentationFormat = navigator.gpu.getPreferredCanvasFormat();
context.configure({
context.configure({
device,
device,
format: presentationFormat,
format: presentationFormat,
alphaMode: 'premultiplied',
alphaMode: 'premultiplied',
});
});
const pipeline = device.createRenderPipeline({
const pipeline = device.createRenderPipeline({
layout: 'auto',
layout: 'auto',
vertex: {
vertex: {
module: device.createShaderModule({
module: device.createShaderModule({
code: fullscreenTexturedQuadWGSL,
code: fullscreenTexturedQuadWGSL,
}),
}),
entryPoint: 'vert_main',
entryPoint: 'vert_main',
},
},
fragment: {
fragment: {
module: device.createShaderModule({
module: device.createShaderModule({
code: sampleExternalTextureWGSL,
code: sampleExternalTextureWGSL,
}),
}),
entryPoint: 'main',
entryPoint: 'main',
targets: [
targets: [
{
{
format: presentationFormat,
format: presentationFormat,
},
},
],
],
},
},
primitive: {
primitive: {
topology: 'triangle-list',
topology: 'triangle-list',
},
},
});
});
const sampler = device.createSampler({
const sampler = device.createSampler({
magFilter: 'linear',
magFilter: 'linear',
minFilter: 'linear',
minFilter: 'linear',
});
});
const settings = {
const settings = {
requestFrame: 'requestAnimationFrame',
requestFrame: 'requestAnimationFrame',
};
};
gui.add(settings, 'requestFrame', [
gui.add(settings, 'requestFrame', [
'requestAnimationFrame',
'requestAnimationFrame',
'requestVideoFrameCallback',
'requestVideoFrameCallback',
]);
]);
function frame() {
function frame() {
// Sample is no longer the active page.
// Sample is no longer the active page.
if (!pageState.active) return;
if (!pageState.active) return;
Copier
Copié
Copier
Copié
const videoFrame = new VideoFrame(video);
const uniformBindGroup = device.createBindGroup({
const uniformBindGroup = device.createBindGroup({
layout: pipeline.getBindGroupLayout(0),
layout: pipeline.getBindGroupLayout(0),
entries: [
entries: [
{
{
binding: 1,
binding: 1,
resource: sampler,
resource: sampler,
},
},
{
{
binding: 2,
binding: 2,
resource: device.importExternalTexture({
resource: device.importExternalTexture({
Copier
Copié
Copier
Copié
source: video
,
source: video
Frame as any, // eslint-disable-line @typescript-eslint/no-explicit-any
}),
}),
},
},
],
],
});
});
const commandEncoder = device.createCommandEncoder();
const commandEncoder = device.createCommandEncoder();
const textureView = context.getCurrentTexture().createView();
const textureView = context.getCurrentTexture().createView();
const renderPassDescriptor: GPURenderPassDescriptor = {
const renderPassDescriptor: GPURenderPassDescriptor = {
colorAttachments: [
colorAttachments: [
{
{
view: textureView,
view: textureView,
clearValue: { r: 0.0, g: 0.0, b: 0.0, a: 1.0 },
clearValue: { r: 0.0, g: 0.0, b: 0.0, a: 1.0 },
loadOp: 'clear',
loadOp: 'clear',
storeOp: 'store',
storeOp: 'store',
},
},
],
],
};
};
const passEncoder = commandEncoder.beginRenderPass(renderPassDescriptor);
const passEncoder = commandEncoder.beginRenderPass(renderPassDescriptor);
passEncoder.setPipeline(pipeline);
passEncoder.setPipeline(pipeline);
passEncoder.setBindGroup(0, uniformBindGroup);
passEncoder.setBindGroup(0, uniformBindGroup);
passEncoder.draw(6);
passEncoder.draw(6);
passEncoder.end();
passEncoder.end();
device.queue.submit([commandEncoder.finish()]);
device.queue.submit([commandEncoder.finish()]);
if (settings.requestFrame == 'requestVideoFrameCallback') {
if (settings.requestFrame == 'requestVideoFrameCallback') {
video.requestVideoFrameCallback(frame);
video.requestVideoFrameCallback(frame);
} else {
} else {
requestAnimationFrame(frame);
requestAnimationFrame(frame);
}
}
}
}
if (settings.requestFrame == 'requestVideoFrameCallback') {
if (settings.requestFrame == 'requestVideoFrameCallback') {
video.requestVideoFrameCallback(frame);
video.requestVideoFrameCallback(frame);
} else {
} else {
requestAnimationFrame(frame);
requestAnimationFrame(frame);
}
}
};
};
Copier
Copié
Copier
Copié
const VideoUploading
: () => JSX.Element = () =>
const VideoUploading
WebCodecs
: () => JSX.Element = () =>
makeSample({
makeSample({
Copier
Copié
Copier
Copié
name: 'Video Uploading
',
name: 'Video Uploading
with WebCodecs
',
description:
'
This example shows how to upload
v
ideo
f
rame to WebGPU.
'
,
description:
`
This example shows how to upload
a WebCodecs V
ideo
F
rame to WebGPU.
`
,
gui: true,
gui: true,
init,
init,
sources: [
sources: [
{
{
name: __filename.substring(__dirname.length + 1),
name: __filename.substring(__dirname.length + 1),
contents: __SOURCE__,
contents: __SOURCE__,
},
},
{
{
name: '../../shaders/fullscreenTexturedQuad.wgsl',
name: '../../shaders/fullscreenTexturedQuad.wgsl',
contents: fullscreenTexturedQuadWGSL,
contents: fullscreenTexturedQuadWGSL,
editable: true,
editable: true,
},
},
{
{
name: '../../shaders/sampleExternalTexture.wgsl',
name: '../../shaders/sampleExternalTexture.wgsl',
contents: sampleExternalTextureWGSL,
contents: sampleExternalTextureWGSL,
editable: true,
editable: true,
},
},
],
],
filename: __filename,
filename: __filename,
});
});
Copier
Copié
Copier
Copié
export default VideoUploading
;
export default VideoUploading
WebCodecs
;
Différences enregistrées
Texte d'origine
Ouvrir un fichier
import { makeSample, SampleInit } from '../../components/SampleLayout'; import fullscreenTexturedQuadWGSL from '../../shaders/fullscreenTexturedQuad.wgsl'; import sampleExternalTextureWGSL from '../../shaders/sampleExternalTexture.frag.wgsl'; const init: SampleInit = async ({ canvas, pageState, gui }) => { // Set video element const video = document.createElement('video'); video.loop = true; video.autoplay = true; video.muted = true; video.src = '../assets/video/pano.webm'; await video.play(); const adapter = await navigator.gpu.requestAdapter(); const device = await adapter.requestDevice(); if (!pageState.active) return; const context = canvas.getContext('webgpu') as GPUCanvasContext; const devicePixelRatio = window.devicePixelRatio; canvas.width = canvas.clientWidth * devicePixelRatio; canvas.height = canvas.clientHeight * devicePixelRatio; const presentationFormat = navigator.gpu.getPreferredCanvasFormat(); context.configure({ device, format: presentationFormat, alphaMode: 'premultiplied', }); const pipeline = device.createRenderPipeline({ layout: 'auto', vertex: { module: device.createShaderModule({ code: fullscreenTexturedQuadWGSL, }), entryPoint: 'vert_main', }, fragment: { module: device.createShaderModule({ code: sampleExternalTextureWGSL, }), entryPoint: 'main', targets: [ { format: presentationFormat, }, ], }, primitive: { topology: 'triangle-list', }, }); const sampler = device.createSampler({ magFilter: 'linear', minFilter: 'linear', }); const settings = { requestFrame: 'requestAnimationFrame', }; gui.add(settings, 'requestFrame', [ 'requestAnimationFrame', 'requestVideoFrameCallback', ]); function frame() { // Sample is no longer the active page. if (!pageState.active) return; const uniformBindGroup = device.createBindGroup({ layout: pipeline.getBindGroupLayout(0), entries: [ { binding: 1, resource: sampler, }, { binding: 2, resource: device.importExternalTexture({ source: video, }), }, ], }); const commandEncoder = device.createCommandEncoder(); const textureView = context.getCurrentTexture().createView(); const renderPassDescriptor: GPURenderPassDescriptor = { colorAttachments: [ { view: textureView, clearValue: { r: 0.0, g: 0.0, b: 0.0, a: 1.0 }, loadOp: 'clear', storeOp: 'store', }, ], }; const passEncoder = commandEncoder.beginRenderPass(renderPassDescriptor); passEncoder.setPipeline(pipeline); passEncoder.setBindGroup(0, uniformBindGroup); passEncoder.draw(6); passEncoder.end(); device.queue.submit([commandEncoder.finish()]); if (settings.requestFrame == 'requestVideoFrameCallback') { video.requestVideoFrameCallback(frame); } else { requestAnimationFrame(frame); } } if (settings.requestFrame == 'requestVideoFrameCallback') { video.requestVideoFrameCallback(frame); } else { requestAnimationFrame(frame); } }; const VideoUploading: () => JSX.Element = () => makeSample({ name: 'Video Uploading', description: 'This example shows how to upload video frame to WebGPU.', gui: true, init, sources: [ { name: __filename.substring(__dirname.length + 1), contents: __SOURCE__, }, { name: '../../shaders/fullscreenTexturedQuad.wgsl', contents: fullscreenTexturedQuadWGSL, editable: true, }, { name: '../../shaders/sampleExternalTexture.wgsl', contents: sampleExternalTextureWGSL, editable: true, }, ], filename: __filename, }); export default VideoUploading;
Texte modifié
Ouvrir un fichier
import { makeSample, SampleInit } from '../../components/SampleLayout'; import fullscreenTexturedQuadWGSL from '../../shaders/fullscreenTexturedQuad.wgsl'; import sampleExternalTextureWGSL from '../../shaders/sampleExternalTexture.frag.wgsl'; const init: SampleInit = async ({ canvas, pageState, gui }) => { // Set video element const video = document.createElement('video'); video.loop = true; video.autoplay = true; video.muted = true; video.src = '../assets/video/pano.webm'; await video.play(); const adapter = await navigator.gpu.requestAdapter(); const device = await adapter.requestDevice(); if (!pageState.active) return; const context = canvas.getContext('webgpu') as GPUCanvasContext; const devicePixelRatio = window.devicePixelRatio; canvas.width = canvas.clientWidth * devicePixelRatio; canvas.height = canvas.clientHeight * devicePixelRatio; const presentationFormat = navigator.gpu.getPreferredCanvasFormat(); context.configure({ device, format: presentationFormat, alphaMode: 'premultiplied', }); const pipeline = device.createRenderPipeline({ layout: 'auto', vertex: { module: device.createShaderModule({ code: fullscreenTexturedQuadWGSL, }), entryPoint: 'vert_main', }, fragment: { module: device.createShaderModule({ code: sampleExternalTextureWGSL, }), entryPoint: 'main', targets: [ { format: presentationFormat, }, ], }, primitive: { topology: 'triangle-list', }, }); const sampler = device.createSampler({ magFilter: 'linear', minFilter: 'linear', }); const settings = { requestFrame: 'requestAnimationFrame', }; gui.add(settings, 'requestFrame', [ 'requestAnimationFrame', 'requestVideoFrameCallback', ]); function frame() { // Sample is no longer the active page. if (!pageState.active) return; const videoFrame = new VideoFrame(video); const uniformBindGroup = device.createBindGroup({ layout: pipeline.getBindGroupLayout(0), entries: [ { binding: 1, resource: sampler, }, { binding: 2, resource: device.importExternalTexture({ source: videoFrame as any, // eslint-disable-line @typescript-eslint/no-explicit-any }), }, ], }); const commandEncoder = device.createCommandEncoder(); const textureView = context.getCurrentTexture().createView(); const renderPassDescriptor: GPURenderPassDescriptor = { colorAttachments: [ { view: textureView, clearValue: { r: 0.0, g: 0.0, b: 0.0, a: 1.0 }, loadOp: 'clear', storeOp: 'store', }, ], }; const passEncoder = commandEncoder.beginRenderPass(renderPassDescriptor); passEncoder.setPipeline(pipeline); passEncoder.setBindGroup(0, uniformBindGroup); passEncoder.draw(6); passEncoder.end(); device.queue.submit([commandEncoder.finish()]); if (settings.requestFrame == 'requestVideoFrameCallback') { video.requestVideoFrameCallback(frame); } else { requestAnimationFrame(frame); } } if (settings.requestFrame == 'requestVideoFrameCallback') { video.requestVideoFrameCallback(frame); } else { requestAnimationFrame(frame); } }; const VideoUploadingWebCodecs: () => JSX.Element = () => makeSample({ name: 'Video Uploading with WebCodecs', description: `This example shows how to upload a WebCodecs VideoFrame to WebGPU.`, gui: true, init, sources: [ { name: __filename.substring(__dirname.length + 1), contents: __SOURCE__, }, { name: '../../shaders/fullscreenTexturedQuad.wgsl', contents: fullscreenTexturedQuadWGSL, editable: true, }, { name: '../../shaders/sampleExternalTexture.wgsl', contents: sampleExternalTextureWGSL, editable: true, }, ], filename: __filename, }); export default VideoUploadingWebCodecs;
Trouver la différence