vkd3d-shader/ir: Allow controlling fog through parameters.

Fog requires several parameters to even implement the most basic of
functionality correctly, so this commit is relatively large.
This commit is contained in:
Elizabeth Figura
2024-10-05 10:26:20 -05:00
committed by Henri Verbeet
parent a1de406de4
commit f86d1e72a4
Notes: Henri Verbeet 2024-12-02 17:19:05 +01:00
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1265
8 changed files with 504 additions and 29 deletions

View File

@@ -476,6 +476,45 @@ enum vkd3d_shader_binding_flag
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_BINDING_FLAG),
};
/**
* The factor used to interpolate the fragment output colour with fog.
*
* See VKD3D_SHADER_PARAMETER_NAME_FOG_FRAGMENT_MODE for specification of the
* interpolation factor as defined here.
*
* The following variables may be used to determine the interpolation factor:
*
* c = The fog coordinate value output from the vertex shader. This is an
* inter-stage varying with the semantic name "FOG" and semantic index 0.
* E = The value of VKD3D_SHADER_PARAMETER_NAME_FOG_END.
* k = The value of VKD3D_SHADER_PARAMETER_NAME_FOG_SCALE.
*
* \since 1.15
*/
enum vkd3d_shader_fog_fragment_mode
{
/**
* No fog interpolation is applied;
* the output colour is passed through unmodified.
* Equivalently, the fog interpolation factor is 1.
*/
VKD3D_SHADER_FOG_FRAGMENT_NONE = 0x0,
/**
* The fog interpolation factor is (E - c) * k.
*
* In order to implement traditional linear fog, as present in Direct3D and
* OpenGL, i.e.
*
* (end - c) / (end - start)
*
* set
*
* E = end
* k = 1 / (end - start)
*/
VKD3D_SHADER_FOG_FRAGMENT_LINEAR = 0x3,
};
/**
* The manner in which a parameter value is provided to the shader, used in
* struct vkd3d_shader_parameter and struct vkd3d_shader_parameter1.
@@ -739,6 +778,73 @@ enum vkd3d_shader_parameter_name
* \since 1.14
*/
VKD3D_SHADER_PARAMETER_NAME_POINT_SPRITE,
/**
* Fog mode used in fragment shaders.
*
* The value specified by this parameter must be a member of
* enum vkd3d_shader_fog_fragment_mode.
*
* If not VKD3D_SHADER_FOG_FRAGMENT_NONE, the pixel shader colour output at
* location 0 is linearly interpolated with the fog colour defined by
* VKD3D_SHADER_PARAMETER_NAME_FOG_COLOUR. The interpolation factor is
* defined according to the enumerant selected by this parameter.
* The interpolated value is then outputted instead of the original value at
* location 0.
*
* An interpolation factor of 0 specifies to use the fog colour; a factor of
* 1 specifies to use the original colour output. The interpolation factor
* is clamped to the [0, 1] range before interpolating.
*
* The default value is VKD3D_SHADER_FOG_FRAGMENT_NONE.
*
* The data type for this parameter must be
* VKD3D_SHADER_PARAMETER_DATA_TYPE_UINT32.
*
* Only VKD3D_SHADER_PARAMETER_TYPE_IMMEDIATE_CONSTANT is supported in this
* version of vkd3d-shader.
*
* \since 1.15
*/
VKD3D_SHADER_PARAMETER_NAME_FOG_FRAGMENT_MODE,
/**
* Fog colour.
* See VKD3D_SHADER_PARAMETER_NAME_FOG_FRAGMENT_MODE for documentation of
* fog.
*
* The data type for this parameter must be
* VKD3D_SHADER_PARAMETER_DATA_TYPE_FLOAT32_VEC4.
*
* The default value is transparent black, i.e. the vector {0, 0, 0, 0}.
*
* \since 1.15
*/
VKD3D_SHADER_PARAMETER_NAME_FOG_COLOUR,
/**
* End coordinate for linear fog.
* See VKD3D_SHADER_PARAMETER_NAME_FOG_FRAGMENT_MODE for documentation of
* fog.
*
* The data type for this parameter must be
* VKD3D_SHADER_PARAMETER_DATA_TYPE_FLOAT32.
*
* The default value is 1.0.
*
* \since 1.15
*/
VKD3D_SHADER_PARAMETER_NAME_FOG_END,
/**
* Scale value for linear fog.
* See VKD3D_SHADER_PARAMETER_NAME_FOG_FRAGMENT_MODE for documentation of
* fog.
*
* The data type for this parameter must be
* VKD3D_SHADER_PARAMETER_DATA_TYPE_FLOAT32.
*
* The default value is 1.0.
*
* \since 1.15
*/
VKD3D_SHADER_PARAMETER_NAME_FOG_SCALE,
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_PARAMETER_NAME),
};