-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Add gfx.device.copyTextureToTexture #17272
Conversation
Interface Check Report! WARNING this pull request has changed these public interfaces:
@@ -9656,8 +9656,9 @@
* @param texture The texture to copy to.
* @param regions The region descriptions.
*/
abstract copyTexImagesToTexture(texImages: Readonly<TexImageSource[]>, texture: Texture, regions: Readonly<BufferTextureCopy[]>): void;
+ abstract copyTextureToTexture(from: Texture, to: Texture, dx: number, dy: number, fromRegion: Readonly<Rect> | null): any;
/**
* @en Whether the device has specific feature.
* @zh 是否具备特性。
* @param feature The GFX feature to be queried.
@@ -45104,8 +45105,9 @@
getBufferBarrier(info: Readonly<gfx.BufferBarrierInfo>): __private._cocos_gfx_base_states_buffer_barrier__BufferBarrier;
copyBuffersToTexture(buffers: Readonly<ArrayBufferView[]>, texture: gfx.Texture, regions: Readonly<gfx.BufferTextureCopy[]>): void;
copyTextureToBuffers(texture: Readonly<gfx.Texture>, buffers: ArrayBufferView[], regions: Readonly<gfx.BufferTextureCopy[]>): void;
copyTexImagesToTexture(texImages: Readonly<TexImageSource[]>, texture: gfx.Texture, regions: Readonly<gfx.BufferTextureCopy[]>): void;
+ copyTextureToTexture(from: gfx.Texture, to: gfx.Texture, dx: number, dy: number, fromRegion: Readonly<gfx.Rect> | null): void;
}
export class WebGLDevice extends gfx.Device {
get gl(): WebGLRenderingContext;
get extensions(): __private._cocos_gfx_webgl_webgl_define__IWebGLExtensions;
@@ -45142,8 +45144,9 @@
getBufferBarrier(info: Readonly<gfx.BufferBarrierInfo>): __private._cocos_gfx_base_states_buffer_barrier__BufferBarrier;
copyBuffersToTexture(buffers: Readonly<ArrayBufferView[]>, texture: gfx.Texture, regions: Readonly<gfx.BufferTextureCopy[]>): void;
copyTextureToBuffers(texture: Readonly<gfx.Texture>, buffers: ArrayBufferView[], regions: Readonly<gfx.BufferTextureCopy[]>): void;
copyTexImagesToTexture(texImages: Readonly<TexImageSource[]>, texture: gfx.Texture, regions: Readonly<gfx.BufferTextureCopy[]>): void;
+ copyTextureToTexture(from: gfx.Texture, to: gfx.Texture, dx: number, dy: number, fromRegion: Readonly<gfx.Rect> | null): void;
}
export class WebGL2Device extends gfx.Device {
get gl(): WebGL2RenderingContext;
get extensions(): __private._cocos_gfx_webgl2_webgl2_define__IWebGL2Extensions;
@@ -45180,8 +45183,9 @@
getBufferBarrier(info: Readonly<gfx.BufferBarrierInfo>): __private._cocos_gfx_base_states_buffer_barrier__BufferBarrier;
copyBuffersToTexture(buffers: Readonly<ArrayBufferView[]>, texture: gfx.Texture, regions: Readonly<gfx.BufferTextureCopy[]>): void;
copyTextureToBuffers(texture: Readonly<gfx.Texture>, buffers: ArrayBufferView[], regions: Readonly<gfx.BufferTextureCopy[]>): void;
copyTexImagesToTexture(texImages: Readonly<TexImageSource[]>, texture: gfx.Texture, regions: Readonly<gfx.BufferTextureCopy[]>): void;
+ copyTextureToTexture(from: gfx.Texture, to: gfx.Texture, dx: number, dy: number, fromRegion: Readonly<gfx.Rect> | null): void;
}
export class WebGPUDevice extends gfx.Device {
createSwapchain(info: Readonly<gfx.SwapchainInfo>): gfx.Swapchain;
getSampler(info: Readonly<gfx.SamplerInfo>): gfx.Sampler;
@@ -45228,8 +45232,9 @@
copyBuffersToTexture(buffers: ArrayBufferView[], texture: gfx.Texture, regions: gfx.BufferTextureCopy[]): void;
copyTexImagesToTexture(texImages: TexImageSource[], texture: gfx.Texture, regions: gfx.BufferTextureCopy[]): void;
copyFramebufferToBuffer(srcFramebuffer: gfx.Framebuffer, dstBuffer: ArrayBuffer, regions: gfx.BufferTextureCopy[]): void;
blitFramebuffer(src: gfx.Framebuffer, dst: gfx.Framebuffer, srcRect: gfx.Rect, dstRect: gfx.Rect, filter: gfx.Filter): void;
+ copyTextureToTexture(from: gfx.Texture, to: gfx.Texture, dx: number, dy: number, fromRegion: Readonly<gfx.Rect> | null): void;
}
/**
* @en Intersection2D helper class
* @zh 辅助类,用于测试形状与形状是否相交
@@ -61128,8 +61133,9 @@
* @param {Texture2D} image
* @param {Number} x
* @param {Number} y
*/
+ drawTextureAt(texture: Texture2D, x: number, y: number): void;
drawTextureAt(image: ImageAsset, x: number, y: number): void;
}
/**
* @en The instance of [[MorphRendering]] for dedicated control in the mesh renderer.
|
gl.copyTexSubImage2D(gl.TEXTURE_2D, 0, dx, dy, srcX, srcY, srcW, srcH); | ||
gl.bindFramebuffer(gl.FRAMEBUFFER, null); | ||
cache.glFramebuffer = null; | ||
gl.deleteFramebuffer(framebuffer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to create / delete FBO each time. Consider to re-use it.
@cocos-robot run test cases |
5 similar comments
@cocos-robot run test cases |
@cocos-robot run test cases |
@cocos-robot run test cases |
@cocos-robot run test cases |
@cocos-robot run test cases |
ffb3265
to
1e4f032
Compare
@cocos-robot run test cases |
3 similar comments
@cocos-robot run test cases |
@cocos-robot run test cases |
@cocos-robot run test cases |
ce703d4
to
f141514
Compare
@cocos-robot run test cases |
1 similar comment
@cocos-robot run test cases |
…85-gfx-copyTextureToTexture
@cocos-robot run test cases |
|
||
GL_CHECK(glBindTexture(dstGPU->glTarget, dstGPU->glTexture)); | ||
cache->glTextures[cache->texUint] = dstGPU->glTexture; | ||
GL_CHECK(glCopyTexSubImage2D(dstGPU->glTarget, 0, dstX, dstY, x, y, w, h)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Memoryleak here. need to invoke glDeleteFramebuffers and reset cache->glReadFramebuffer to 0.
@cocos-robot run test cases |
Re: #17268
This PR was originally developed by @zhoujianbo0
Changelog
Continuous Integration
This pull request:
Compatibility Check
This pull request: