Metal: implement support for compressed textures #119835

Merged
Aras Pranckevicius merged 2 commits from aras_p/blender:mtl-compressed-textures into main 2024-03-25 11:40:29 +01:00

Noticed lack of it via #119793. Now DDS images using BC1/BC2/BC3 (aka DXT1/DXT3/DXT5) formats can keep on being GPU compressed on Metal too, just like e.g. on OpenGL.

Repro attached to #119841 can be used for testing.

I will do Vulkan side in a separate PR, since that one does not handle compressed textures properly either, it seems.

Noticed lack of it via #119793. Now DDS images using BC1/BC2/BC3 (aka DXT1/DXT3/DXT5) formats can keep on being GPU compressed on Metal too, just like e.g. on OpenGL. Repro attached to #119841 can be used for testing. I will do Vulkan side in a separate PR, since that one does not handle compressed textures properly either, it seems.
Aras Pranckevicius added 1 commit 2024-03-23 20:41:24 +01:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
2b9f81e0cd
Metal: implement support for compressed textures
Author
Member

@blender-bot build

@blender-bot build
Clément Foucault requested changes 2024-03-23 20:50:04 +01:00
Dismissed
@ -757,1 +761,4 @@
size_t bytes_per_image = bytes_per_row;
if (is_compressed) {
size_t block_size = to_block_size(format_);
size_t blocks_x = (extent[0] + 3) / 4;

We have divide_ceil_u() for this.

We have `divide_ceil_u()` for this.
aras_p marked this conversation as resolved

I believe this makes #119793 obsolete, once this is merged.

I believe this makes #119793 obsolete, once this is merged.
Aras Pranckevicius added 1 commit 2024-03-24 08:51:20 +01:00
Aras Pranckevicius requested review from Clément Foucault 2024-03-24 08:51:38 +01:00
Omar Emara reviewed 2024-03-24 12:02:51 +01:00
Omar Emara left a comment
Member

gpu::MTLTexture::read seems suspicious, since it asserts for compressed textures. Maybe this is related to why it wasn't implemented. Do you happened to know anything about that?

`gpu::MTLTexture::read` seems suspicious, since it asserts for compressed textures. Maybe this is related to why it wasn't implemented. Do you happened to know anything about that?
Author
Member

gpu::MTLTexture::read seems suspicious, since it asserts for compressed textures. Maybe this is related to why it wasn't implemented. Do you happened to know anything about that?

@OmarEmaraDev I don't, but OpenGL implementation has the same assert: BLI_assert(!(format_flag_ & GPU_FORMAT_COMPRESSED));. So I guess whatever read does (I don't even know), is not supposed to be called on compressed textures. Vulkan texture implementation does not have the assert, but it seems like it does not handle compressed textures either (hmm maybe I should fix that too?)

> `gpu::MTLTexture::read` seems suspicious, since it asserts for compressed textures. Maybe this is related to why it wasn't implemented. Do you happened to know anything about that? @OmarEmaraDev I don't, but OpenGL implementation has the same assert: `BLI_assert(!(format_flag_ & GPU_FORMAT_COMPRESSED));`. So I guess whatever read does (I don't even know), is not supposed to be called on compressed textures. Vulkan texture implementation does not have the assert, but it seems like it does not handle compressed textures either (hmm maybe I should fix that too?)

Reading Compressed format is never used. So no need to implement this.

Reading Compressed format is never used. So no need to implement this.
Clément Foucault approved these changes 2024-03-25 11:25:45 +01:00
Aras Pranckevicius merged commit 26337b9fb4 into main 2024-03-25 11:40:29 +01:00
Aras Pranckevicius deleted branch mtl-compressed-textures 2024-03-25 11:40:32 +01:00
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser Project (Legacy)
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#119835
No description provided.