-
-
Notifications
You must be signed in to change notification settings - Fork 12
Restore configurable texture filtering #130
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| #!/usr/bin/env python3 | ||
| """Static contract for the user-selectable default texture sampler.""" | ||
|
|
||
| from pathlib import Path | ||
|
|
||
|
|
||
| ROOT = Path(__file__).resolve().parents[2] | ||
|
|
||
|
|
||
| def read(path: str) -> str: | ||
| return (ROOT / path).read_text(encoding="utf-8") | ||
|
|
||
|
|
||
| def require(text: str, token: str, context: str) -> None: | ||
| if token not in text: | ||
| raise AssertionError(f"Missing {token!r} in {context}") | ||
|
|
||
|
|
||
| def main() -> None: | ||
| header = read("src/renderer/Image.h") | ||
| manager = read("src/renderer/ImageManager.cpp") | ||
| gl_image = read("src/renderer/OpenGL/gl_Image.cpp") | ||
| vk_image = read("src/renderer/Vulkan/vk_Image.cpp") | ||
| docs = read("docs/user/display-settings.md") | ||
| validator = read("tools/validation/openq4_validate.py") | ||
|
|
||
| filter_values = ( | ||
| "GL_LINEAR_MIPMAP_LINEAR", | ||
| "GL_LINEAR_MIPMAP_NEAREST", | ||
| "GL_NEAREST", | ||
| "GL_LINEAR", | ||
| "GL_NEAREST_MIPMAP_NEAREST", | ||
| "GL_NEAREST_MIPMAP_LINEAR", | ||
| ) | ||
| args_start = manager.index("static const char *image_filterArgs[]") | ||
| args_end = manager.index("};", args_start) | ||
| args_block = manager[args_start:args_end] | ||
| positions = [args_block.index(f'"{value}"') for value in filter_values] | ||
| if positions != sorted(positions): | ||
| raise AssertionError("image_filter value order no longer matches imageFilterMode_t") | ||
|
|
||
| require(manager, 'idCVar image_filter(', "image_filter registration") | ||
| require(manager, '"GL_LINEAR_MIPMAP_LINEAR",\n\tCVAR_RENDERER | CVAR_ARCHIVE', "image_filter default and persistence") | ||
| require(manager, "idCmdSystem::ArgCompletion_String<image_filterArgs>", "image_filter completion") | ||
| require(manager, "&image_filter, &image_anisotropy", "live sampler CVar tracking") | ||
| require(manager, "image->GetFilter() == TF_DEFAULT", "authored filter isolation") | ||
| require(manager, "image->RefreshSamplerState();", "live sampler refresh") | ||
|
|
||
| for value in filter_values: | ||
| require(header, f"IMAGE_FILTER_{value.removeprefix('GL_')}", "backend-neutral filter modes") | ||
| require(docs, f"`{value}`", "texture-filter documentation") | ||
|
|
||
| require(header, "imageFilterState_t R_GetDefaultImageFilterState();", "shared filter resolver") | ||
| require(gl_image, "defaultFilter.usesMipmaps", "OpenGL mip selection") | ||
| require(gl_image, "defaultFilter.minLinear", "OpenGL texel selection") | ||
| require(gl_image, "defaultFilter.mipLinear", "OpenGL mip blending") | ||
| require(gl_image, "void idImage::RefreshSamplerState()", "OpenGL live refresh") | ||
|
|
||
| require(vk_image, "defaultFilterMode", "Vulkan sampler cache key") | ||
| require(vk_image, "defaultFilter.magLinear ? VK_FILTER_LINEAR : VK_FILTER_NEAREST", "Vulkan magnification selection") | ||
| require(vk_image, "defaultFilter.mipLinear ? VK_SAMPLER_MIPMAP_MODE_LINEAR", "Vulkan mip blending") | ||
| require(vk_image, "void idImage::RefreshSamplerState()", "Vulkan live refresh") | ||
|
|
||
| require(docs, "seta image_filter GL_NEAREST_MIPMAP_NEAREST", "pixelated-texture example") | ||
| require( | ||
| validator, | ||
| 'root / "tools" / "tests" / "renderer_texture_filter.py"', | ||
| "validation-suite registration", | ||
| ) | ||
|
|
||
| print("renderer_texture_filter: ok") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
When Vulkan users repeatedly switch
image_filteror adjustimage_anisotropy, each mode/anisotropy/repeat/mip combination is retained until device shutdown because the new mode is part of the cache key. Refreshing all loaded default-filter images can therefore consume the fixed 64-entry cache during a normal session; subsequent misses returnvkSamplers[0], applying an unrelated filter or address mode to textures. Evict stale default samplers or otherwise bound/reuse these setting-dependent entries.Useful? React with 👍 / 👎.