Skip to content

Commit

Permalink
Fix compilation errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
dumganhar committed Jul 2, 2024
1 parent e1b1832 commit ea70a77
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 17 deletions.
3 changes: 1 addition & 2 deletions cocos/gfx/base/device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
ShaderInfo, InputAssemblerInfo, RenderPassInfo, FramebufferInfo, DescriptorSetLayoutInfo, PipelineLayoutInfo,
QueueInfo, BufferTextureCopy, DeviceInfo, DeviceCaps, GeneralBarrierInfo, TextureBarrierInfo, BufferBarrierInfo,
SwapchainInfo, BindingMappingInfo, Format, FormatFeature, TextureType, TextureUsageBit,
TextureFlagBit, Offset, Extent, SampleCount, TextureSubresLayers, TextureUsage, TextureFlags, Rect
TextureFlagBit, Offset, Extent, SampleCount, TextureSubresLayers, TextureUsage, TextureFlags, Rect,
} from './define';
import { Buffer } from './buffer';
import { CommandBuffer } from './command-buffer';
Expand Down Expand Up @@ -344,7 +344,6 @@ export abstract class Device {
*/
public abstract copyTexImagesToTexture (texImages: Readonly<TexImageSource[]>, texture: Texture, regions: Readonly<BufferTextureCopy[]>): void;


public abstract copyTextureToTexture(from: Texture, to: Texture, dx: number, dy: number, fromRegion: Readonly<Rect> | null);

/**
Expand Down
5 changes: 5 additions & 0 deletions cocos/gfx/empty/empty-device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import {
QueueInfo, CommandBufferInfo, DescriptorSetInfo, DescriptorSetLayoutInfo, FramebufferInfo, InputAssemblerInfo, PipelineLayoutInfo,
RenderPassInfo, SamplerInfo, TextureInfo, TextureViewInfo, BufferInfo, BufferViewInfo, DeviceInfo, TextureBarrierInfo, GeneralBarrierInfo,
BufferBarrierInfo, QueueType, API, BufferTextureCopy, SwapchainInfo,
Rect,
} from '../base/define';
import { GeneralBarrier } from '../base/states/general-barrier';
import { TextureBarrier } from '../base/states/texture-barrier';
Expand Down Expand Up @@ -225,6 +226,10 @@ export class EmptyDevice extends Device {
public copyTexImagesToTexture (texImages: Readonly<TexImageSource[]>, texture: Texture, regions: Readonly<BufferTextureCopy[]>): void {
// noop
}

public copyTextureToTexture (from: Texture, to: Texture, dx: number, dy: number, fromRegion: Readonly<Rect> | null): void {
//
}
}

cclegacy.EmptyDevice = EmptyDevice;
13 changes: 7 additions & 6 deletions cocos/gfx/webgl/webgl-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ export class WebGLCmdDraw extends WebGLCmdObject {
}

public clear (): void {
//
}
}

Expand Down Expand Up @@ -3081,14 +3082,14 @@ export function WebGLCmdFuncCopyTextureToTexture (
dstGPUTexture: IWebGLGPUTexture,
dx: number,
dy: number,
srcRect: Readonly<Rect> | null
srcRect: Readonly<Rect> | null,
): void {
const { gl } = device;
const cache = device.stateCache;

if (dstGPUTexture.glTarget != gl.TEXTURE_2D) {

Check warning on line 3090 in cocos/gfx/webgl/webgl-commands.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Expected '!==' and instead saw '!='
error('Unsupported GL dst texture type, copy texture to texture failed.');
return ;
return;
}

let srcX = 0;
Expand All @@ -3097,15 +3098,15 @@ export function WebGLCmdFuncCopyTextureToTexture (
let srcH = srcGPUTextrue.height;
if (srcRect) {
if (srcRect.x + srcRect.width > srcGPUTextrue.width || srcRect.y + srcRect.height > srcGPUTextrue.height) {
return ;
return;
//error('Unsupported GL dst texture type, copy texture to texture failed.');
}
}
srcX = srcRect.x;
srcY = srcRect.y;
srcW = srcRect.width;
srcH = srcRect.height;
}
if (dx + srcW > dstGPUTexture.width || dy + srcH > dstGPUTexture.height) return ;
if (dx + srcW > dstGPUTexture.width || dy + srcH > dstGPUTexture.height) return;

const framebuffer = gl.createFramebuffer();
gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
Expand All @@ -3119,4 +3120,4 @@ export function WebGLCmdFuncCopyTextureToTexture (
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
cache.glFramebuffer = null;
gl.deleteFramebuffer(framebuffer);
}
}
4 changes: 2 additions & 2 deletions cocos/gfx/webgl/webgl-device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import {
QueueInfo, CommandBufferInfo, DescriptorSetInfo, DescriptorSetLayoutInfo, FramebufferInfo, InputAssemblerInfo, PipelineLayoutInfo,
RenderPassInfo, SamplerInfo, TextureInfo, TextureViewInfo, BufferInfo, BufferViewInfo, DeviceInfo, TextureBarrierInfo, GeneralBarrierInfo,
BufferBarrierInfo, QueueType, API, Feature, BufferTextureCopy, SwapchainInfo, FormatFeature, FormatFeatureBit, Format,
Offset, Rect
Offset, Rect,
} from '../base/define';
import { WebGLCmdFuncCopyBuffersToTexture, WebGLCmdFuncCopyTextureToBuffers, WebGLCmdFuncCopyTexImagesToTexture, WebGLCmdFuncCopyTextureToTexture } from './webgl-commands';

Check warning on line 61 in cocos/gfx/webgl/webgl-device.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

This line has a length of 172. Maximum allowed is 150
import { GeneralBarrier } from '../base/states/general-barrier';
Expand Down Expand Up @@ -570,7 +570,7 @@ export class WebGLDevice extends Device {
);
}

public copyTextureToTexture(from: Texture, to: Texture, dx: number, dy: number, fromRegion: Readonly<Rect> | null) {
public copyTextureToTexture (from: Texture, to: Texture, dx: number, dy: number, fromRegion: Readonly<Rect> | null): void {
WebGLCmdFuncCopyTextureToTexture(this, (from as WebGLTexture).gpuTexture, (to as WebGLTexture).gpuTexture, dx, dy, fromRegion);
}
}
10 changes: 5 additions & 5 deletions cocos/gfx/webgl2/webgl2-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3467,14 +3467,14 @@ export function WebGL2CmdFuncCopyTextureToTexture (
dstGPUTexture: IWebGL2GPUTexture,
dx: number,
dy: number,
srcRect: Readonly<Rect> | null
srcRect: Readonly<Rect> | null,
): void {
const { gl } = device;
const cache = device.stateCache;

if (dstGPUTexture.glTarget != gl.TEXTURE_2D) {

Check warning on line 3475 in cocos/gfx/webgl2/webgl2-commands.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Expected '!==' and instead saw '!='
error('Unsupported GL dst texture type, copy texture to texture failed.');
return ;
return;
}

let srcX = 0;
Expand All @@ -3483,15 +3483,15 @@ export function WebGL2CmdFuncCopyTextureToTexture (
let srcH = srcGPUTextrue.height;
if (srcRect) {
if (srcRect.x + srcRect.width > srcGPUTextrue.width || srcRect.y + srcRect.height > srcGPUTextrue.height) {
return ;
return;
//error('Unsupported GL dst texture type, copy texture to texture failed.');
}
}
srcX = srcRect.x;
srcY = srcRect.y;
srcW = srcRect.width;
srcH = srcRect.height;
}
if (dx + srcW > dstGPUTexture.width || dy + srcH > dstGPUTexture.height) return ;
if (dx + srcW > dstGPUTexture.width || dy + srcH > dstGPUTexture.height) return;
const framebuffer = gl.createFramebuffer();
gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, srcGPUTextrue.glTarget, srcGPUTextrue.glTexture, 0);
Expand Down
4 changes: 2 additions & 2 deletions cocos/gfx/webgl2/webgl2-device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ import {
PipelineLayoutInfo, BufferViewInfo, CommandBufferInfo, BufferInfo, FramebufferInfo, InputAssemblerInfo,
QueueInfo, RenderPassInfo, SamplerInfo, ShaderInfo, TextureInfo, TextureViewInfo, DeviceInfo, GeneralBarrierInfo, TextureBarrierInfo,
BufferBarrierInfo, QueueType, API, Feature, BufferTextureCopy, SwapchainInfo, FormatFeature, Format, FormatFeatureBit,
Offset, Rect
Offset, Rect,
} from '../base/define';
import { WebGL2CmdFuncCopyTextureToBuffers, WebGL2CmdFuncCopyBuffersToTexture, WebGL2CmdFuncCopyTexImagesToTexture, WebGL2CmdFuncCopyTextureToTexture } from './webgl2-commands';

Check warning on line 62 in cocos/gfx/webgl2/webgl2-device.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

This line has a length of 177. Maximum allowed is 150
import { GeneralBarrier } from '../base/states/general-barrier';
Expand Down Expand Up @@ -637,7 +637,7 @@ export class WebGL2Device extends Device {
);
}

public copyTextureToTexture(from: Texture, to: Texture, dx: number, dy: number, fromRegion: Readonly<Rect> | null) {
public copyTextureToTexture (from: Texture, to: Texture, dx: number, dy: number, fromRegion: Readonly<Rect> | null): void {
WebGL2CmdFuncCopyTextureToTexture(this, (from as WebGL2Texture).gpuTexture, (to as WebGL2Texture).gpuTexture, dx, dy, fromRegion);
}
}

0 comments on commit ea70a77

Please sign in to comment.