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
texture.lock({ level: 0 }): only upload a single mip level if locked explicitly #6004
Comments
Hi @liamdon , Sorry it's taken so long to get back to you. This part of the engine sorely needs love and it's great to have you onboard!
cc @mvaligursky, who might have some things to add especially from restrictions on the WebGPU side. |
|
Nice, thanks. Fortunately most of these differences are hidden inside the respective platform implementations (webgl-texture, webgl-device, webgpu-texture etc). In terms of this public texture API, do you see any potential issues @mvaligursky? |
Nope, the API suggestions sound great. Even though it probably not hurt to refactor the WebglTexture class a bit to make it more flexible, before implementing the changes - to make the code easier to follow. |
related ticket: #4290 |
I also have some questions about future directions
texture.lock()
API, which I would be happy to help implement.I'm asking these in the context of #6003 - I kept that PR deliberately small, but can open a followup PR depending on your thoughts.
Apologies in advance for length!
Questions for PlayCanvas team
Question 1
As mentioned in #5754, it would be good to be able to:
I'm excited to contribute an implementation for 1), but first I would like to clarify some issues around 2) and 3).
On 3): it looks to me like we always re-upload all mip levels regardless of whether we locked a specific one.
Q1: Is this correct, or have I missed something important in webgl/webgpu-texture.js?
Question 2
We could check
texture._lockedLevel
and use it to only upload the specified level when alevel
option was passed totexture.lock()
.For example in
webgl-texture.js
:Q2: Does this seem like a good approach? Or should we be checking / updating
texture._levelsUpdated
instead?Question 3
texture.lockedLevel
defaults to0
when nolevel
option is passed._lockedLevel !== -1
is overloaded to indicate whether a texture is locked._lockedMode
for this instead, and leave_lockedLevel
at-1
if no explicit level was specified.The default API would have the same behavior as now:
But when the user specifies mip level 0 explicitly:
So for most cases of
lock()
, the behavior is the same, but it could break expectations in code that is passing{ level: 0 }
and expecting all mips to update.Additionally, anyone relying on the private
texture._lockedLevel
would not longer see it set to0
when a texture is locked in the default way. But they could switch to the publictexture.lockMode
instead to check the locked state.Q3: Is this level of API/behavior change acceptable?
Thank you, and let me know if there is a better venue for implementation questions like this!
The text was updated successfully, but these errors were encountered: