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

Replace texture image data #176

Merged
merged 5 commits into from
Mar 30, 2024
Merged

Replace texture image data #176

merged 5 commits into from
Mar 30, 2024

Conversation

misdake
Copy link
Contributor

@misdake misdake commented Mar 14, 2024

Fixes #147.

  1. add TextureLoader trait with load_texture and replace_texture
  2. implement TextureLoader for all 4 engines
    • dx9 and dx12: load_texture = heap.create_texture + heap.upload_texture, replace_texture = heap.upload_texture
    • dx11 and gl3: load_texture = heap.create_texture (with init), replace_texture = heap.update_texture

"Allow edits by maintainers" is on. If you have any suggestions for improvement, just push changes to this branch, specially about naming and code repetition.

@misdake
Copy link
Contributor Author

misdake commented Mar 14, 2024

I'd say tests are now scary as hell.
image

Copy link
Owner

@veeenu veeenu left a comment

Choose a reason for hiding this comment

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

That's a scary swole doge if I've ever seen one. 😅

Style looks good to me in general, please allow me a bit of time so I can review it properly but it's going in the right direction.

This will probably warrant a breaking semver minor bump to 0.7 since the public API is getting changed.

Thank you!

src/renderer/pipeline.rs Show resolved Hide resolved
Copy link
Owner

@veeenu veeenu left a comment

Choose a reason for hiding this comment

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

Thank you, this is great! Works fine on Wine too.

I have just a couple observations/nits for style, and one important request for compat.

Note: After this gets merged in, we'll have to bump to 0.7.0 due to breaking changes and update hudbook accordingly.

src/lib.rs Show resolved Hide resolved
src/lib.rs Show resolved Hide resolved
src/lib.rs Show resolved Hide resolved
src/renderer/backend/dx11.rs Outdated Show resolved Hide resolved
src/renderer/backend/dx12.rs Outdated Show resolved Hide resolved
src/renderer/backend/dx9.rs Outdated Show resolved Hide resolved
src/renderer/backend/opengl3.rs Outdated Show resolved Hide resolved
@misdake misdake requested a review from veeenu March 27, 2024 03:41
Copy link
Owner

@veeenu veeenu left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you so much 🙌

@veeenu veeenu merged commit 19e2f1f into veeenu:main Mar 30, 2024
1 check passed
@veeenu veeenu mentioned this pull request Mar 30, 2024
@misdake misdake deleted the replace_texture branch April 2, 2024 03:13
@Godnoken
Copy link
Contributor

Godnoken commented Feb 14, 2025

I've been trying to implement similar functionality from inside the renderloop (I am passing the swapchain to it), using hudhook 0.4(?), and only managed to do so for OpenGL so far. DX9 crashes no matter what, DX11 displays random white symbols (what?) and DX12 is not tested. I'm not entirely sure if it is even possible without modifying the hudhook code.

From what I can tell, the current functionality on hudhook 0.8 only allows the upload of textures from the initializing stage. Is this correct?


Edit;

I've dived into the code a little bit now. Clearly, DX9, DX11 and DX12 completely lacked this functionality before, hence why I can't implement it. I'll probably have to take the plunge, bump up and try to transfer my much needed modifications to my own repo.

I noticed the the RenderContext is passed to before_render but not render. I assume that there is a very good reason for this?

@veeenu
Copy link
Owner

veeenu commented Feb 16, 2025

render takes a frame object that immutably borrows from Context, which then makes it impossible to mutably borrow from it in order to upload textures. before_render is called back just before that happens and gives access to a mutable reference to Context. Textures can be uploaded and modified any time in before_render -- it gets called for every frame, and it requires some state tracking, but of course it's not advisable to actually swap textures at every frame. 😅

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.

Replace texture image data
3 participants