[Mesa-dev] [PATCH 11/14] mesa/main: Maintain compressed TexEnv Combine state.
Gustaw Smolarczyk
wielkiegie at gmail.com
Fri Apr 7 17:04:51 UTC 2017
2017-04-07 16:40 GMT+02:00 Marek Olšák <maraeo at gmail.com>:
> On Fri, Apr 7, 2017 at 4:35 PM, Marek Olšák <maraeo at gmail.com> wrote:
>> On Thu, Mar 30, 2017 at 8:09 PM, Gustaw Smolarczyk <wielkiegie at gmail.com> wrote:
>>> Signed-off-by: Gustaw Smolarczyk <wielkiegie at gmail.com>
>>> ---
>>> src/mesa/main/mtypes.h | 83 ++++++++++++++++++++++++++++++++++++++
>>> src/mesa/main/texstate.c | 103 +++++++++++++++++++++++++++++++++++++++++++++++
>>> 2 files changed, 186 insertions(+)
>>>
>>> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
>>> index 186d79928c..369d2327f2 100644
>>> --- a/src/mesa/main/mtypes.h
>>> +++ b/src/mesa/main/mtypes.h
>>> @@ -1078,6 +1078,87 @@ struct gl_tex_env_combine_state
>>> };
>>>
>>>
>>> +/** Compressed TexEnv effective Combine mode */
>>> +enum gl_tex_env_mode
>>> +{
>>> + TEXENV_MODE_REPLACE, /* r = a0 */
>>> + TEXENV_MODE_MODULATE, /* r = a0 * a1 */
>>> + TEXENV_MODE_ADD, /* r = a0 + a1 */
>>> + TEXENV_MODE_ADD_SIGNED, /* r = a0 + a1 - 0.5 */
>>> + TEXENV_MODE_INTERPOLATE, /* r = a0 * a2 + a1 * (1 - a2) */
>>> + TEXENV_MODE_SUBTRACT, /* r = a0 - a1 */
>>> + TEXENV_MODE_DOT3_RGB, /* r = a0 . a1 */
>>> + TEXENV_MODE_DOT3_RGB_EXT, /* r = a0 . a1 */
>>> + TEXENV_MODE_DOT3_RGBA, /* r = a0 . a1 */
>>> + TEXENV_MODE_DOT3_RGBA_EXT, /* r = a0 . a1 */
>>> + TEXENV_MODE_MODULATE_ADD_ATI, /* r = a0 * a2 + a1 */
>>> + TEXENV_MODE_MODULATE_SIGNED_ADD_ATI, /* r = a0 * a2 + a1 - 0.5 */
>>> + TEXENV_MODE_MODULATE_SUBTRACT_ATI, /* r = a0 * a2 - a1 */
>>> + TEXENV_MODE_ADD_PRODUCTS_NV, /* r = a0 * a1 + a2 * a3 */
>>> + TEXENV_MODE_ADD_PRODUCTS_SIGNED_NV, /* r = a0 * a1 + a2 * a3 - 0.5 */
>>> +};
>>> +
>>> +
>>> +/** Compressed TexEnv Combine source */
>>> +enum gl_tex_env_source
>>> +{
>>> + TEXENV_SRC_TEXTURE0,
>>> + TEXENV_SRC_TEXTURE1,
>>> + TEXENV_SRC_TEXTURE2,
>>> + TEXENV_SRC_TEXTURE3,
>>> + TEXENV_SRC_TEXTURE4,
>>> + TEXENV_SRC_TEXTURE5,
>>> + TEXENV_SRC_TEXTURE6,
>>> + TEXENV_SRC_TEXTURE7,
>>> + TEXENV_SRC_TEXTURE,
>>> + TEXENV_SRC_PREVIOUS,
>>> + TEXENV_SRC_PRIMARY_COLOR,
>>> + TEXENV_SRC_CONSTANT,
>>> + TEXENV_SRC_ZERO,
>>> + TEXENV_SRC_ONE,
>>> +};
>>> +
>>> +
>>> +/** Compressed TexEnv Combine operand */
>>> +enum gl_tex_env_operand
>>> +{
>>> + TEXENV_OPR_COLOR,
>>> + TEXENV_OPR_ONE_MINUS_COLOR,
>>> + TEXENV_OPR_ALPHA,
>>> + TEXENV_OPR_ONE_MINUS_ALPHA,
>>> +};
>>> +
>>> +
>>> +/** Compressed TexEnv Combine argument */
>>> +struct gl_tex_env_argument
>>> +{
>>> +#ifdef __GNUC__
>>> + __extension__ uint8_t Source:4; /**< TEXENV_SRC_x */
>>> + __extension__ uint8_t Operand:2; /**< TEXENV_OPR_x */
>>> +#else
>>> + uint8_t Source; /**< SRC_x */
>>> + uint8_t Operand; /**< OPR_x */
Oops, I left the old comments here. Should be the same as above.
>>> +#endif
>>
>> Why is this #ifdef here?
I have copied it from ff_fragment_shader.cpp.
>
> You can just use "unsigned Source:4;" There is no reason to do it any other way.
There is one: using unsigned instead of uint8_t makes sizeof(struct
gl_tex_env_argument) be 4 instead of 1. I assume that is also the
reason it was done this way in ff_fragment_shader.cpp (though in C++
using uint8_t for a bitfield is ok and isn't an extension, IIRC).
I can try to pursue some other alternative if you don't like
special-casing for gcc here. I can just use uint8_t and make inline
functions/macros that pack/unpack Source and Operand from it.
Gustaw
More information about the mesa-dev
mailing list