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
4 changes: 2 additions & 2 deletions src/renderers/common/RenderContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,9 @@ class RenderContext {
*/
export function getCacheKey( renderContext ) {

const { textures, activeCubeFace } = renderContext;
const { textures, activeCubeFace, activeMipmapLevel } = renderContext;

const values = [ activeCubeFace ];
const values = [ activeCubeFace, activeMipmapLevel ];
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We must honor the active map level in the render context cache in the same way like the active cube face since we need separate framebuffers/view descriptors for each mip.


for ( const texture of textures ) {

Expand Down
10 changes: 7 additions & 3 deletions src/renderers/webgl-fallback/WebGLBackend.js
Original file line number Diff line number Diff line change
Expand Up @@ -2092,8 +2092,9 @@ class WebGLBackend extends Backend {
const { textureGPU } = this.get( textures[ 0 ] );

const cubeFace = this.renderer._activeCubeFace;
const mipLevel = this.renderer._activeMipmapLevel;

gl.framebufferTexture2D( gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + cubeFace, textureGPU, 0 );
gl.framebufferTexture2D( gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + cubeFace, textureGPU, mipLevel );

} else {

Expand All @@ -2115,8 +2116,9 @@ class WebGLBackend extends Backend {
} else if ( isRenderTarget3D || isRenderTargetArray ) {

const layer = this.renderer._activeCubeFace;
const mipLevel = this.renderer._activeMipmapLevel;

gl.framebufferTextureLayer( gl.FRAMEBUFFER, attachment, textureData.textureGPU, 0, layer );
gl.framebufferTextureLayer( gl.FRAMEBUFFER, attachment, textureData.textureGPU, mipLevel, layer );

} else {

Expand All @@ -2126,7 +2128,9 @@ class WebGLBackend extends Backend {

} else {

gl.framebufferTexture2D( gl.FRAMEBUFFER, attachment, gl.TEXTURE_2D, textureData.textureGPU, 0 );
const mipLevel = this.renderer._activeMipmapLevel;

gl.framebufferTexture2D( gl.FRAMEBUFFER, attachment, gl.TEXTURE_2D, textureData.textureGPU, mipLevel );
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes to gl.framebufferTexture2D() and gl.framebufferTextureLayer() make sure the framebuffers for each mipmap are correctly coupled to the texture's mip levels.


}

Expand Down
2 changes: 0 additions & 2 deletions src/renderers/webgpu/WebGPUBackend.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,6 @@ class WebGPUBackend extends Backend {
if ( descriptors === undefined ||
renderTargetData.width !== renderTarget.width ||
renderTargetData.height !== renderTarget.height ||
renderTargetData.activeMipmapLevel !== renderContext.activeMipmapLevel ||
renderTargetData.activeCubeFace !== renderContext.activeCubeFace ||
Copy link
Collaborator Author

@Mugen87 Mugen87 Aug 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to reset the descriptor cache when the active mipmap level or cube face changes. The respective texture views should be cached so they are not created over and over again when changing the rendering settings.

renderTargetData.samples !== renderTarget.samples
) {

Expand Down
Loading