Skip to content

Allow contexts to share data tables#591

Merged
solidpixel merged 6 commits intomainfrom
context_sharing
Mar 26, 2026
Merged

Allow contexts to share data tables#591
solidpixel merged 6 commits intomainfrom
context_sharing

Conversation

@solidpixel
Copy link
Contributor

@solidpixel solidpixel commented Mar 26, 2026

This PR changes astcenc_context_alloc() to accept a parent context from which data tables can be inherited. Descendent contexts use the same astcenc_config settings as their parent to ensure that the data tables will match.

Parent contexts must not be freed by the caller until all descendent contexts have been freed.

Fixes #588

This PR changes astcenc_context_alloc() to accept a parent context
from which data tables can be inherited. Descendent contexts
must use the same astcenc_config settings as their parent, otherwise
the data tables will mismatch.

Parent contexts must not be freed by the caller until all descendent
contexts have been freed.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR extends the public ASTC encoder API to allow creating a codec context that inherits read-only data tables from a parent context, reducing per-context memory use for multi-image parallel workloads (Fixes #588).

Changes:

  • Updated astcenc_context_alloc() signature to accept an optional parent_context for table inheritance.
  • Added internal ownership tracking for the shared block_size_descriptor and adjusted allocation/free paths accordingly.
  • Updated call sites, public docs, unit test usage, and changelog to reflect the new API.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
Utils/Example/astc_api_example.cpp Updates example to call the new astcenc_context_alloc(..., nullptr) signature.
Source/astcenccli_toplevel.cpp Updates CLI to use the new astcenc_context_alloc(..., nullptr) signature.
Source/astcenc_internal.h Adds owns_bsd, makes bsd shared/const, and updates aligned_free() to handle const pointers.
Source/astcenc_entry.cpp Implements parent-context inheritance for bsd and gates freeing based on ownership.
Source/astcenc.h Documents the new parent_context parameter and updates usage examples.
Source/UnitTest/test_decode.cpp Updates unit test to call the new API signature.
Docs/ChangeLog-5x.md Adds release notes for context table sharing and mentions public API change.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@solidpixel solidpixel merged commit 8e46004 into main Mar 26, 2026
9 checks passed
@solidpixel solidpixel deleted the context_sharing branch March 26, 2026 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow context creation to accept a parent context

2 participants