-
Notifications
You must be signed in to change notification settings - Fork 125
Allow Manually Created Textures in IECoreGL::Shader::Setup #1282
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
Allow Manually Created Textures in IECoreGL::Shader::Setup #1282
Conversation
The path forward is pretty simple : one day you pass the type to the Texture constructor, and remove the type from the
For me, this is a pretty big one. Why introduce an API feature if we can't support it properly, and will delete it later anyway?
I'm afraid I'm inclined to think that. I'd rather have a minimal localised workaround than introduce a temporary class that doesn't fulfil its promise. The approach we originally agreed is a tiny addition to the API surface area, and I really don't think it's that weird : |
|
Alternative thought : we do know the type of the uniform parameter we're setting, so can we just derive the texture target from that? |
fb159f6 to
1b3976a
Compare
|
Switched to deducing texture target from the sampler, and everything appears to still be working. |
johnhaddon
left a comment
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.
LGTM. I assume we want it on RB-10.4 though?
include/IECoreGL/RawTexture.h
Outdated
| // Needed to do some hackery in Texture and Shader since the base class doesn't yet know about | ||
| // targetType | ||
| friend Texture; | ||
| friend Shader; |
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.
Why wouldn't we just provide a public query for the target type?
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.
I'm really confused by this comment and the next one ... since you decided we wouldn't go with the version of the code that uses RawTexture. I was freaked out that I may have uploaded the wrong version, but looking at this PR now, I only see one commit, and it doesn't add RawTexture ... I guess you were looking at something out of date?
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.
Oh, yeah, that is freaky. Those are comments I made during my first review - I definitely didn't intentionally repeat them for this one, as there was only that one commit to look at. I guess we put it down to a GitHub bug...
Just to be completely clear, this LGTM, so feel free to merge once you've retargeted it to RB-10.4.
src/IECoreGL/Shader.cpp
Outdated
| TextureValue( GLuint uniformIndex, GLuint textureUnit, ConstTexturePtr texture ) | ||
| : m_uniformIndex( uniformIndex ), m_textureUnit( textureUnit ), m_texture( texture ) | ||
| { | ||
| const RawTexture *rawTexture = dynamic_cast< const RawTexture* >( texture.get() ); |
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.
Since RawTexture is RunTimeTyped, I think this should be runTimeCast?
| // \todo : Needed by hack in Shader::Setup::MemberData::TextureValue until we are able | ||
| // to break ABI and add targetType support to Texture | ||
| friend class Shader; |
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.
At some point I think we might as well add a public accessor for the texture ID anyway.
I've left the V1 commit in the history, even though we agreed that we won't be using that approach.
Thinking about trying to actually use Texture to store the textures, adding API to Shader::Setup that takes a separate target felt very wrong, since the target is so clearly part of the Texture - in particular, there wouldn't be any nice path forward for code written using this weird API.
What I've ended up with here is a subclass RawTexture that adds the target type.
Pros: No modification needed to Shader::Setup API. Decent path forward in the long run - once we can change the API, RawTexture becomes a synonym/shim for Texture.
Cons: Some weird friend declarations needed to mess around with private stuff in the meantime. Shader::ScopedBinding doesn't work with RawTexture ( because ~ScopedBinding can't have any way to access the Texture or its type without breaking ABI ). I was feeling pretty proud of this plan until I realized that spanner in the works, but at least I can error clearly on that case, so maybe it's still OK?
Or maybe this was all a waste of time and I should have just gone with implementing the weird API on Shader::Setup::addUniformParameterWithOverriddenTextureTarget?