Skip to content
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

fix DDS_FLAGS for exported dds files #23

Merged
merged 3 commits into from
Jun 18, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ jobs:

- name: Tests for Windows
if: runner.os == 'Windows'
run: pytest tests -svv
run: pytest -p no:faulthandler tests -svv
env:
BLENDER_EXECUTABLE: ${{ steps.install-dependencies-windows.outputs.blender-executable }}

Expand Down
14 changes: 7 additions & 7 deletions addons/blender_dds_addon/directx/dds.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,20 +105,20 @@ class DDS_FLAGS(IntEnum):
CAPS = 0x1
HEIGHT = 0x2
WIDTH = 0x4
PITCH = 0x8 # Use "w * h * bpp" for pitch_or_linear_size
PITCH = 0x8 # Use "w * bpp" for pitch_or_linear_size
PIXELFORMAT = 0x1000
MIPMAPCOUNT = 0x20000
LINEARSIZE = 0x80000 # Use "w * bpp" for pitch_or_linear_size
LINEARSIZE = 0x80000 # Use "w * h * bpp" for pitch_or_linear_size
DEPTH = 0x800000 # For volume textures
DEFAULT = CAPS | HEIGHT | WIDTH | PIXELFORMAT | MIPMAPCOUNT

@staticmethod
def get_flags(is_compressed, is_3d):
flags = DDS_FLAGS.DEFAULT
if is_compressed:
flags |= DDS_FLAGS.PITCH
else:
flags |= DDS_FLAGS.LINEARSIZE
else:
flags |= DDS_FLAGS.PITCH
if is_3d:
flags |= DDS_FLAGS.DEPTH
return flags
Expand Down Expand Up @@ -343,9 +343,9 @@ def update(self, depth, array_size):

self.flags = DDS_FLAGS.get_flags(self.is_compressed(), is_3d)
if DDS_FLAGS.has_pitch(self.flags):
self.pitch_or_linear_size = int(self.width * self.height * bpp)
else:
self.pitch_or_linear_size = int(self.width * bpp)
else:
self.pitch_or_linear_size = int(self.width * self.height * bpp)
self.caps = DDS_CAPS.get_caps(has_mips, is_cube)
self.caps2 = DDS_CAPS2.get_caps2(is_cube, is_3d)

Expand All @@ -354,7 +354,7 @@ def update(self, depth, array_size):

def get_bpp(self):
bpp = self.pitch_or_linear_size // self.width
if DDS_FLAGS.has_pitch(self.flags):
if not DDS_FLAGS.has_pitch(self.flags):
bpp = bpp // self.height
return bpp

Expand Down
2 changes: 2 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
- Fixed a bug that exported dds files have wrong flags.

ver 0.4.1
- Added support for drag-drop import

Expand Down
1 change: 1 addition & 0 deletions external/build_astcenc.bat
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ cmake -G "%VS_VERSION%"^
-D ASTCENC_CLI=OFF^
-D ASTCENC_ISA_SSE2=ON^
-D ASTCENC_SHAREDLIB=ON^
-D CMAKE_CXX_FLAGS='-D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR'^
../

cmake --build . --config Release
Expand Down