Skip to content
Snippets Groups Projects

vkd3d-shader/hlsl: Initialize static variables to 0 by default.

Merged Francisco Casas requested to merge fcasas/vkd3d:static_ini_zero into master

We are currently not initializing static values to zero by default.

Consider the following shader:

static float4 va;

float4 main() : sv_target
{
  return va;
}

we get the following output:

ps_5_0
dcl_output o0.xyzw
dcl_temps 2
mov r0.xyzw, r1.xyzw
mov o0.xyzw, r0.xyzw
ret

where r1.xyzw is not initialized.

This patch solves this by assigning the static variable the value of an uint 0, and thus, relying on complex broadcasts.

This seems to be the behaviour of the the native compiler, since it retrieves the following error on a shader that lacks an initializer on a data type with object components:

error X3017: cannot convert from 'uint' to 'struct <unnamed>'

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
Please register or sign in to reply
Loading