On Fri Mar 22 20:59:49 2024 +0000, Nikolay Sivov wrote:
> My concern, just by looking at it, is about how hard would it be to
> extract relevant cases from instructions. Is it easy to tell already
> that we got a constant load, array variable load with constant index,
> array variable load with variable index, or more complicated expression?
> Those are important to distinguish, because they are encoded differently.
well, first we have to find out if native does some compilation passes such as copy-propagation and constant folding to lower complicated expressions into constants, and apply those passes. For instance, are rhs expressions such as `ANISOTROPIC + 1` marked as a of the _constant load_ type in the effects metadata?
After applying the passes we have to check the type of the last instruction of the block (or args[0], in case ths is not a complex initializer with braces) which represents the whole expression, and see if it is HLSL_IR_CONSTANT, HLSL_IR_INDEX (in which case we have to check if the index part is constant) or HLSL_IR_EXPR.
We should also probably introduce a pass exclusive to fx.c to lower known HLSL_IR_UNDECLARED_LOAD into constants, so constant folding (if required) can work.
I don't know yet how complex initializers with braces work in this case, if at all, but they parse.
--
https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/739#note_65852
Zebediah Figura (@zfigura) commented about libs/vkd3d-shader/hlsl.h:
> /* Scope that contains annotations for this variable. */
> struct hlsl_scope *annotations;
>
> - /* The state block on the variable's declaration, if any.
> + /* A list containing the state block on the variable's declaration, if any.
> + * An array variable may contain multiple state blocks.
> * These are only really used for effect profiles. */
> - struct hlsl_state_block *state_block;
> + struct list state_blocks;
Do we really want this to be a list? I feel like an array is probably going to be nicer to work with...
--
https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/739#note_65851
Zebediah Figura (@zfigura) commented about libs/vkd3d-shader/hlsl.h:
> HLSL_IR_STORE,
> HLSL_IR_SWIZZLE,
> HLSL_IR_SWITCH,
> + HLSL_IR_UNDECLARED_LOAD,
I don't like this name. It's not a load, since it's not coming from a variable. I would rather say something like "effect constant" or "stateblock constant".
--
https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/739#note_65850
Zebediah Figura (@zfigura) commented about tests/hlsl/fx-syntax.shader_test:
> + pass
> + {
> + cat = SetPixelShader(foobar);
> + }
> +}
> +
> +
> +% Test use of a DepthStencilState in SetDepthStencilState().
> +[pixel shader todo]
> +DepthStencilState dss1
> +{
> + DepthEnable = false;
> + DepthWriteMask = Zero;
> + DepthFunc = Less;
> + foobar_Field = 22;
> +};
This test is a bit weird, because as we've seen, SetDepthStencilState() doesn't even validate anything [unless we're in an effect target, presumably]. Is this actually testing anything?
--
https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/739#note_65849