Jump to content
  • Advertisement
Sign in to follow this  

X4580 this variable dependent on potentially uninitialized data

This topic is 393 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

void GS(triangle PSInputPositionNormalTexture input[3],
    inout TriangleStream< PSInputPositionNormalTexture > output_stream) {

    // Calculate the dominant direction of the surface normal.
    // Face normal based on the triangle edges:
    // normalize(cross(input[1].p_view - input[0].p_view, 
    //                 input[2].p_view - input[0].p_view))
    // Normalization is not needed (i.e. uniform scaling):
    const float3 abs_n = abs(cross(input[1].p_view - input[0].p_view, 
                                   input[2].p_view - input[0].p_view));
    const uint dir_xy = (abs_n.x > abs_n.y)       ? 0u : 1u;
    const uint dir    = (abs_n.z > abs_n[dir_xy]) ? 2u : dir_xy;
    PSInputPositionNormalTexture output[3];

    // Project the triangle in the dominant direction for rasterization (p),
    // but not for lighting (p_view).
    for (uint i = 0u; i < 3u; ++i) {
        output[i].p.xyz = input[i].p_view - g_voxel_grid_center;
        if (0u == dir) {
            output[i].p.xy = output[i].p.yz;
        } else if (1u == dir) {
            output[i].p.xy = output[i].p.zx;

        // [m] * [voxels/m] * [1/voxels]
        output[i].p.xy  *= (g_voxel_grid_inv_size * g_voxel_grid_inv_resolution);
        output[i].p.zw   = float2(0.0f, 1.0f);
        output[i].p.zw   = float2(1.0f, 1.0f);
        output[i].p_view = input[i].p_view;
        output[i].n_view = input[i].n_view;
        output[i].tex    = input[i].tex;
        output[i].tex2   = input[i].tex2;
    // For each projected triangle, a slightly larger bounding triangle ensures 
    // that any projected triangle touching a pixel will necessarily touch the 
    // center of this pixel and thus will get a fragment emitted by the rasterizer.
    const float2 delta_10 = normalize(output[1].p.xy - output[0].p.xy);
    const float2 delta_21 = normalize(output[2].p.xy - output[1].p.xy);
    const float2 delta_02 = normalize(output[0].p.xy - output[2].p.xy);
    // Move vertices for conservative rasterization.
    output[0].p.xy += normalize(delta_02 - delta_10) * g_voxel_grid_inv_resolution;
    output[1].p.xy += normalize(delta_10 - delta_21) * g_voxel_grid_inv_resolution;
    output[2].p.xy += normalize(delta_21 - delta_02) * g_voxel_grid_inv_resolution;

    // Output a triangle strip of three vertices.
    for (uint j = 0u; j < 3u; ++j) {
        // Output a vertex.

    // End the current triangle strip.

I switched to SM 5.1 and suddenly the warnings I originally got, but couldn't explain, mutated into errors.

FXC gives me 6 identical, cryptical, just-figure-it-out-yourself errors:

Error    X4580    emitting a system-interpreted value which is not written in every execution path of the shader. Unconditional initialization may help.

Beside these (which were originally just warnings), I now also got another 4 errors:

Error    X4580    this variable dependent on potentially uninitialized data: delta_10
Error    X4580    this variable dependent on potentially uninitialized data: delta_10  
Error    X4580    this variable dependent on potentially uninitialized data: delta_02  
Error    X4580    this variable dependent on potentially uninitialized data: delta_02

and are associated with the block of code beneath the 

"Move vertices for conservative rasterization." 

But as one can see very clearly, my parameters and all their channels are completely initialized?


Edited by matt77hias

Share this post

Link to post
Share on other sites

This solves the issue, though the compiler is wrong.

const float3 p_voxel = input[i].p_view - g_voxel_grid_center;
if (0u == dir) {
  output[i].p.xy = p_voxel.yz;
else if (1u == dir) {
  output[i].p.xy = p_voxel.zx;
else {
  output[i].p.xy = p_voxel.xy;


Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!