-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
state parameters should be an array instead of a list of named parameters #85
Comments
Yes, but in the meantime you can have a look at the schemas, the states are listed there. |
cullFaceEnabled default value is set to 'false' in the schema. |
depthTestEnable default values is set to 'false' and should be 'true' |
ditherEnable is listed ... I thought glFT would not support dither? |
I would like to change the spec. Instead of using objects when there are multiple parameters, I would like to use an array for the parameters to array. so instead of
this would be (I'm not sure of the schema
|
We still need to address the parameters by index, so using keys instead doesn't seem a bit deal. |
It's way more complicated in the code, since object properties are not The difference is about 50 lines of code, and lost of possible typos. On Fri, May 3, 2013 at 9:27 AM, Fabrice Robinet notifications@github.comwrote:
|
In general I think Fabrice got carried away using properties instead of On Fri, May 3, 2013 at 10:11 AM, Rémi Arnaud notifications@github.comwrote:
Tony Parisi tparisi@gmail.com Read my book! WebGL, Up and Running |
@tparisi it's not the same situation here. These properties are scoped within the described function, these are not uniqueIDs meant to be referred by other objects. So arrays can work, but I brought issues related to validation in this case. |
@RemiArnaud I see, apply is indeed convenient in this case for WebGL. I just have 2 concerns:
|
@pjcozzi What do you think ? |
Well how important is validation in this case? I have seen many instances of specs in the past that were designed in less than ideal ways in order to be able to validate input (X3D comes to mind). We can't let validation be the enemy of ease of implementation; the two need to work together in synergy. Patrick and I were discussing validation the other day and I can't remember what the feature was, but he was saying there were already a few features that couldn't be validated by schema and would require additional tools. @pjcozzi , do you recall? |
@RemiArnaud looks like this issue is tracking at least 2 different things.
To ease @pjcozzi catching up with all this, |
This does not match the WebGL spec.
This does not match the WebGL spec.
We just haven't removed it yet.
Things I like about this:
Things I don't like:
I see the trade-off like this: if most clients will never need to access individual properties, then @RemiArnaud's proposal is OK; otherwise, the existing design is.
In general, I agree with @tparisi's point that we can't let JSON validation drive the design. Our plan - I believe - has always been to use JSON schema for coarse-grained validation as best as it can, and then to write a fine-grained validator (perhaps in JavaScript using node.js), which can go way beyond what JSON schema can check for. |
r/e validation, we have to get our priorities straight. My favorite war Our priorities should be
On Tue, Jun 4, 2013 at 5:25 AM, Patrick Cozzi notifications@github.comwrote:
Tony Parisi tparisi@gmail.com Read my book! WebGL, Up and Running |
@RemiArnaud @pjcozzi @pjcozzi anyhow, as a related fact we need to separate states per profile. Overall, as pointed out by Patrick, the current design addresses more use cases since one can still access properties by name, for individual access it would be cumbersome to do it by index. |
I tried a bit more, it looks than on Chrome / Firefox apply is way slower, but on safari direct,call and apply are more of less equivalent. |
I don't understand this discussion. How did we go from using array instead of list of objects in the glTF format end up at looking at performance of apply() vs. native call ? This is a mystery to me... I don't even see the connection. Can we delete all this discussion about apply and get back to the core of the issue please? |
@RemiArnaud this was your comment to propose this: "states": { |
@RemiArnaud @pjcozzi if we re-focus on the original issue - matching the title of this issue, it's fine with me too. |
Ok, my bad, I mentioned implementation specific detail as an example, which de-routed the entire conversation to discuss the example implementation rather than the design itself. So to get back to the core issue: parameters in javascript are provided/defined by their order in the call. The way to represent this in JSON is to provide an array, which keeps the parameters in the same order of the parameters of the WebGL function call. In the current specification, the application has to know for every state function which function parameter matches with witch parameter name. - instead of just applying the parameters in the order they come in the glTF. So, it what strikes me is that we are adding named parameters in glTF, and in turn need to also parse and manage those names for each state in the loader. This is more work, more data, more parsing for nothing. In fact, this is not friendly to adding new states in the future, as applications will have to be edited and maintain this list of named parameters for each new state added. I have a hard time to see any reason for the current specification. |
I 'fixed' the title |
If I understand @RemiArnaud correctly, it sounds like if we design
Although I love the conciseness, I don't know how many folks will do this in practice. Most engines will want to access specific states as cleanly as possible (without index). Examples:
In addition, using arrays here is inconsistent with the rest of glTF, which maps WebGL parameters to names, not array elements. |
I don't understand The application can and should manage states, but all the parameters are needed for each state change. So what is the point of managing each parameter individually? |
Maybe to provide more explanation, I not understand why having access to parameters by name of a state is necessary, If you want and choke at the idea of using indexes, you can wrap this easily like that:
Another way, less modern, is to create your state object at load time
This is one optional file to write once for everyone to use. On the other hand, having objects instead of a simple array in the glTF file MANDATE that everybody uses the following type of code:
And it make the glFT file bigger for no reason other than code styling. Like I said there is no need to separate each value of a state with its own name, because a state is atomic, you can't change a part of it, you have to have all the parameters, in the exact order defined for that state. glTF should be as close to the target platform and as straight forward to load as possible. The current specification mandates the glTF importer to have a parser, when it is definitely not necessary. So overall, I am saying that in the code you can use array/index or properties (.xxx notation), regardless of how it is stored in glTF, but that I am advocating is that the loader code does not have to do any parsing when not necessary, and that the specification statically defined information should not be part of glTF. There is already a spec that says what parameter is where in each state. So why do I have to duplicate this in each glTF document? Why do I have to have a parser code that duplicate that in the code ? |
I agree that this can be more straight forward if we go #96 (comment) @RemiArnaud @pjcozzi Please try to reach agreement ASAP, I need to move on the code, quite late already. |
I still don't agree with this design based on everything I've already said, but I don't want to hold us up. If @RemiArnaud wants to update the spec (and related examples), then it is OK with me if it helps us move forward. |
Will be able to update the spec when back end of July. Also, would love to use values rather than strings in the state parameters. Regards |
Talked to @fabrobinet offline, we agreed to leave the stencil functions for a minor revision and to change the {
// This object will be empty/not-present by default since all states are disabled by default
"enable" : {
BLEND : false,
CULL_FACE : false,
DEPTH_TEST : false,
POLYGON_OFFSET_FILL : false,
SAMPLE_ALPHA_TO_COVERAGE : false,
SAMPLE_COVERAGE : false,
SCISSOR_TEST : false
},
"functions" : {
"blendColor": [0.0, 0.0, 0.0, 0.0], // (red, green, blue, alpha)
"blendEquationSeparate" : [FUNC_ADD, FUNC_ADD], // (rgb, alpha)
"blendFuncSeparate" : [ONE, ONE, ZERO, ZERO], // (srcRGB, srcAlpha, dstRGB, dstAlpha)
"colorMask" : [true, true, true, true], // (red, green, blue, alpha)
"cullFace" : [BACK],
"depthFunc" : [LESS],
"depthMask" : [true],
"depthRange" : [0.0, 1.0], // (zNear, zFar)
"frontFace" : [CCW],
"lineWidth" : [1.0],
"polygonOffset" : [0.0, 0.0], // (factor, units)
"sampleCoverage" : [1.0, false], // (value, invert)
"scissor" : [0, 0, 0, 0], // (x, y, width, height)
}
} Any feedback? If we are all in agreement, @fabrobinet can you do the converter updates? Outstanding questions from above (I am OK pushing both of them):
|
Thanks @patrick , sure I'll wait a bit a and make the converter updates.
|
This will require implementations to assign to |
I would see it as a semantic in parameters. |
OK, let's discuss in #83. Anyone have more feedback here? |
FYI - I just made a minor update to the above to remove |
moving forward and implementing this now, will merge dev-8 into master once it is done. |
actually we finally agreed to keep |
@pjcozzi I think we should better not touch SAMPLE_COVERAGE . if someone instantiate a context with anti-aliasing, this will be set to |
but still, we want to manage SAMPLE_ALPHA_TO_COVERAGE . |
I think that will be fine. Let me confirm on Monday when I am available. |
damn, what's exported by the converter is not following the proposal. |
And it is ready here: #318 |
Removing {
"enable" : [BLEND, CULL_FACE, DEPTH_TEST, POLYGON_OFFSET_FILL, SAMPLE_ALPHA_TO_COVERAGE, SCISSOR_TEST], // empty by default
"functions" : {
"blendColor": [0.0, 0.0, 0.0, 0.0], // (red, green, blue, alpha)
"blendEquationSeparate" : [FUNC_ADD, FUNC_ADD], // (rgb, alpha)
"blendFuncSeparate" : [ONE, ONE, ZERO, ZERO], // (srcRGB, srcAlpha, dstRGB, dstAlpha)
"colorMask" : [true, true, true, true], // (red, green, blue, alpha)
"cullFace" : [BACK],
"depthFunc" : [LESS],
"depthMask" : [true],
"depthRange" : [0.0, 1.0], // (zNear, zFar)
"frontFace" : [CCW],
"lineWidth" : [1.0],
"polygonOffset" : [0.0, 0.0], // (factor, units)
"scissor" : [0, 0, 0, 0], // (x, y, width, height)
}
} I am updating the schema in |
Updated |
Useful comment from #249 (duplicate): #249 (comment) |
@tparisi here is content on render states for the draft 1.0 spec: Render states define the fixed-function GL state when a
Valid values for elements in the Each property in The following example "states" : {
"enable" : [BLEND, CULL_FACE, DEPTH_TEST, POLYGON_OFFSET_FILL, SAMPLE_ALPHA_TO_COVERAGE, SCISSOR_TEST], // empty by default
"functions" : {
"blendColor": [0.0, 0.0, 0.0, 0.0], // (red, green, blue, alpha)
"blendEquationSeparate" : [FUNC_ADD, FUNC_ADD], // (rgb, alpha)
"blendFuncSeparate" : [ONE, ONE, ZERO, ZERO], // (srcRGB, srcAlpha, dstRGB, dstAlpha)
"colorMask" : [true, true, true, true], // (red, green, blue, alpha)
"cullFace" : [BACK],
"depthFunc" : [LESS],
"depthMask" : [true],
"depthRange" : [0.0, 1.0], // (zNear, zFar)
"frontFace" : [CCW],
"lineWidth" : [1.0],
"polygonOffset" : [0.0, 0.0], // (factor, units)
"scissor" : [0, 0, 0, 0], // (x, y, width, height)
}
} The following example shows a typical "states": {
"enable": [
2884,
2929
]
} Implementation Note: It is recommended that a runtime use the minimal number of GL state function calls. This generally means ordering draw calls by technique, and then only making GL state function calls for the states that vary between techniques. Of course, this will also need a table that containing the schema details: https://github.com/KhronosGroup/glTF/blob/spec-1.0/specification/schema/examples/techniques.json |
for example:
the spec needs the entire list to be defined so the application know what to expect
The text was updated successfully, but these errors were encountered: