Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shaders load but don't work #12655

Closed
USLTD opened this issue Mar 10, 2022 · 23 comments · Fixed by #12677
Closed

Shaders load but don't work #12655

USLTD opened this issue Mar 10, 2022 · 23 comments · Fixed by #12677
Labels
Area-Rendering Text rendering, emoji, complex glyph & font-fallback issues Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-2 A description (P2) Product-Terminal The new Windows Terminal. Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release.
Milestone

Comments

@USLTD
Copy link

USLTD commented Mar 10, 2022

Windows Terminal version

1.13.10336.0 Preview

Windows build number

10.0.19042.1586

Other Software

No response

Steps to reproduce

I have downloaded https://github.com/microsoft/terminal/blob/main/samples/PixelShaders/Rasterbars.hlsl as test.hlsl file and placed it in *C:\TMP* directory. Then I changed my Windows Terminal configuration like below:

{
    "$help": "https://aka.ms/terminal-documentation",
    "$schema": "https://aka.ms/terminal-profiles-schema",
    "actions": 
    [
        {
            "command": "toggleShaderEffects",
            "keys": "shift+f10"
        },
        {
            "command": "paste",
            "keys": "ctrl+v"
        },
        {
            "command": 
            {
                "action": "copy",
                "singleLine": false
            },
            "keys": "ctrl+c"
        },
        {
            "command": "toggleFocusMode",
            "keys": "shift+f11"
        },
        {
            "command": "find",
            "keys": "ctrl+shift+f"
        },
        {
            "command": 
            {
                "action": "splitPane",
                "split": "auto",
                "splitMode": "duplicate"
            },
            "keys": "alt+shift+d"
        }
    ],
    "alwaysShowNotificationIcon": true,
    "defaultProfile": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
    "profiles": 
    {
        "defaults": 
        {
            "experimental.pixelShaderPath": "C:\\TMP\\test.hlsl",
            "experimental.useAtlasEngine": false,
            "font": 
            {
                "face": "FiraCode NF"
            }
        },
        "list": 
        [
            {
                "commandline": "%SystemRoot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
                "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
                "hidden": false,
                "name": "Windows PowerShell"
            },
            {
                "commandline": "%SystemRoot%\\System32\\cmd.exe",
                "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
                "hidden": false,
                "name": "Command Prompt"
            },
            {
                "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
                "hidden": false,
                "name": "Azure Cloud Shell",
                "source": "Windows.Terminal.Azure"
            },
            {
                "guid": "{2ece5bfe-50ed-5f3a-ab87-5cd4baafed2b}",
                "hidden": false,
                "name": "Git Bash",
                "source": "Git"
            },
            {
                "guid": "{58ad8b0c-3ef8-5f4d-bc6f-13e4c00f2530}",
                "hidden": false,
                "name": "Debian",
                "source": "Windows.Terminal.Wsl"
            }
        ]
    },
    "schemes": 
    [
        {
            "background": "#0C0C0C",
            "black": "#0C0C0C",
            "blue": "#0037DA",
            "brightBlack": "#767676",
            "brightBlue": "#3B78FF",
            "brightCyan": "#61D6D6",
            "brightGreen": "#16C60C",
            "brightPurple": "#B4009E",
            "brightRed": "#E74856",
            "brightWhite": "#F2F2F2",
            "brightYellow": "#F9F1A5",
            "cursorColor": "#FFFFFF",
            "cyan": "#3A96DD",
            "foreground": "#CCCCCC",
            "green": "#13A10E",
            "name": "Campbell",
            "purple": "#881798",
            "red": "#C50F1F",
            "selectionBackground": "#FFFFFF",
            "white": "#CCCCCC",
            "yellow": "#C19C00"
        },
        {
            "background": "#012456",
            "black": "#0C0C0C",
            "blue": "#0037DA",
            "brightBlack": "#767676",
            "brightBlue": "#3B78FF",
            "brightCyan": "#61D6D6",
            "brightGreen": "#16C60C",
            "brightPurple": "#B4009E",
            "brightRed": "#E74856",
            "brightWhite": "#F2F2F2",
            "brightYellow": "#F9F1A5",
            "cursorColor": "#FFFFFF",
            "cyan": "#3A96DD",
            "foreground": "#CCCCCC",
            "green": "#13A10E",
            "name": "Campbell Powershell",
            "purple": "#881798",
            "red": "#C50F1F",
            "selectionBackground": "#FFFFFF",
            "white": "#CCCCCC",
            "yellow": "#C19C00"
        },
        {
            "background": "#282C34",
            "black": "#282C34",
            "blue": "#61AFEF",
            "brightBlack": "#5A6374",
            "brightBlue": "#61AFEF",
            "brightCyan": "#56B6C2",
            "brightGreen": "#98C379",
            "brightPurple": "#C678DD",
            "brightRed": "#E06C75",
            "brightWhite": "#DCDFE4",
            "brightYellow": "#E5C07B",
            "cursorColor": "#FFFFFF",
            "cyan": "#56B6C2",
            "foreground": "#DCDFE4",
            "green": "#98C379",
            "name": "One Half Dark",
            "purple": "#C678DD",
            "red": "#E06C75",
            "selectionBackground": "#FFFFFF",
            "white": "#DCDFE4",
            "yellow": "#E5C07B"
        },
        {
            "background": "#FAFAFA",
            "black": "#383A42",
            "blue": "#0184BC",
            "brightBlack": "#4F525D",
            "brightBlue": "#61AFEF",
            "brightCyan": "#56B5C1",
            "brightGreen": "#98C379",
            "brightPurple": "#C577DD",
            "brightRed": "#DF6C75",
            "brightWhite": "#FFFFFF",
            "brightYellow": "#E4C07A",
            "cursorColor": "#4F525D",
            "cyan": "#0997B3",
            "foreground": "#383A42",
            "green": "#50A14F",
            "name": "One Half Light",
            "purple": "#A626A4",
            "red": "#E45649",
            "selectionBackground": "#FFFFFF",
            "white": "#FAFAFA",
            "yellow": "#C18301"
        },
        {
            "background": "#002B36",
            "black": "#002B36",
            "blue": "#268BD2",
            "brightBlack": "#073642",
            "brightBlue": "#839496",
            "brightCyan": "#93A1A1",
            "brightGreen": "#586E75",
            "brightPurple": "#6C71C4",
            "brightRed": "#CB4B16",
            "brightWhite": "#FDF6E3",
            "brightYellow": "#657B83",
            "cursorColor": "#FFFFFF",
            "cyan": "#2AA198",
            "foreground": "#839496",
            "green": "#859900",
            "name": "Solarized Dark",
            "purple": "#D33682",
            "red": "#DC322F",
            "selectionBackground": "#FFFFFF",
            "white": "#EEE8D5",
            "yellow": "#B58900"
        },
        {
            "background": "#FDF6E3",
            "black": "#002B36",
            "blue": "#268BD2",
            "brightBlack": "#073642",
            "brightBlue": "#839496",
            "brightCyan": "#93A1A1",
            "brightGreen": "#586E75",
            "brightPurple": "#6C71C4",
            "brightRed": "#CB4B16",
            "brightWhite": "#FDF6E3",
            "brightYellow": "#657B83",
            "cursorColor": "#002B36",
            "cyan": "#2AA198",
            "foreground": "#657B83",
            "green": "#859900",
            "name": "Solarized Light",
            "purple": "#D33682",
            "red": "#DC322F",
            "selectionBackground": "#FFFFFF",
            "white": "#EEE8D5",
            "yellow": "#B58900"
        },
        {
            "background": "#000000",
            "black": "#000000",
            "blue": "#3465A4",
            "brightBlack": "#555753",
            "brightBlue": "#729FCF",
            "brightCyan": "#34E2E2",
            "brightGreen": "#8AE234",
            "brightPurple": "#AD7FA8",
            "brightRed": "#EF2929",
            "brightWhite": "#EEEEEC",
            "brightYellow": "#FCE94F",
            "cursorColor": "#FFFFFF",
            "cyan": "#06989A",
            "foreground": "#D3D7CF",
            "green": "#4E9A06",
            "name": "Tango Dark",
            "purple": "#75507B",
            "red": "#CC0000",
            "selectionBackground": "#FFFFFF",
            "white": "#D3D7CF",
            "yellow": "#C4A000"
        },
        {
            "background": "#FFFFFF",
            "black": "#000000",
            "blue": "#3465A4",
            "brightBlack": "#555753",
            "brightBlue": "#729FCF",
            "brightCyan": "#34E2E2",
            "brightGreen": "#8AE234",
            "brightPurple": "#AD7FA8",
            "brightRed": "#EF2929",
            "brightWhite": "#EEEEEC",
            "brightYellow": "#FCE94F",
            "cursorColor": "#000000",
            "cyan": "#06989A",
            "foreground": "#555753",
            "green": "#4E9A06",
            "name": "Tango Light",
            "purple": "#75507B",
            "red": "#CC0000",
            "selectionBackground": "#FFFFFF",
            "white": "#D3D7CF",
            "yellow": "#C4A000"
        },
        {
            "background": "#000000",
            "black": "#000000",
            "blue": "#000080",
            "brightBlack": "#808080",
            "brightBlue": "#0000FF",
            "brightCyan": "#00FFFF",
            "brightGreen": "#00FF00",
            "brightPurple": "#FF00FF",
            "brightRed": "#FF0000",
            "brightWhite": "#FFFFFF",
            "brightYellow": "#FFFF00",
            "cursorColor": "#FFFFFF",
            "cyan": "#008080",
            "foreground": "#C0C0C0",
            "green": "#008000",
            "name": "Vintage",
            "purple": "#800080",
            "red": "#800000",
            "selectionBackground": "#FFFFFF",
            "white": "#C0C0C0",
            "yellow": "#808000"
        }
    ]
}

Expected Behavior

RasterBars

Actual Behavior

Screenshot (2)

@USLTD USLTD added the Issue-Bug It either shouldn't be doing this or needs an investigation. label Mar 10, 2022
@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Mar 10, 2022
@USLTD
Copy link
Author

USLTD commented Mar 10, 2022

I have also seen #9354 and #9058 but those say that bug was fixed in Windows Terminal Preview v1.8.1032.0 while I have a later version.

@zadjii-msft
Copy link
Member

Ah, shaders don't work with the atlas engine quite yet. This is tracked as a bullet point in #9999 but I'll leave this open to track it fully. Thanks!

@zadjii-msft zadjii-msft added Area-AtlasEngine Area-Rendering Text rendering, emoji, complex glyph & font-fallback issues Priority-2 A description (P2) Product-Terminal The new Windows Terminal. labels Mar 10, 2022
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Mar 10, 2022
@zadjii-msft zadjii-msft added this to the 22H1 milestone Mar 10, 2022
@zadjii-msft zadjii-msft removed the Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting label Mar 10, 2022
@USLTD
Copy link
Author

USLTD commented Mar 10, 2022

@zadjii-msft I will try without Atlas engine.
Edit: No effect. Still nothing

@lhecker
Copy link
Member

lhecker commented Mar 10, 2022

@UltraStudioLTD Did you set your antialiasingMode to cleartype? If so: That doesn't seem to work at the moment.
Otherwise, could you update or post your settings.json?

@USLTD
Copy link
Author

USLTD commented Mar 10, 2022

@lhecker It didn't work. I updated setting.json file posted to match currently used.

@lhecker
Copy link
Member

lhecker commented Mar 10, 2022

@UltraStudioLTD You have "antialiasingMode": "cleartype", in your settings. Remove that line and it will work. 🙂

@USLTD
Copy link
Author

USLTD commented Mar 10, 2022

@lhecker It didn't work.

@USLTD
Copy link
Author

USLTD commented Mar 10, 2022

By the way here is C:\TMP\test.hlsl file

// A minimal pixel shader that shows some raster bars

// The terminal graphics as a texture
Texture2D shaderTexture;
SamplerState samplerState;

// Terminal settings such as the resolution of the texture
cbuffer PixelShaderSettings {
  // The number of seconds since the pixel shader was enabled
  float  Time;
  // UI Scale
  float  Scale;
  // Resolution of the shaderTexture
  float2 Resolution;
  // Background color as rgba
  float4 Background;
};

// A pixel shader is a program that given a texture coordinate (tex) produces a color.
// tex is an x,y tuple that ranges from 0,0 (top left) to 1,1 (bottom right).
// Just ignore the pos parameter.
float4 main(float4 pos : SV_POSITION, float2 tex : TEXCOORD) : SV_TARGET
{
    // Read the color value at the current texture coordinate (tex)
    //  float4 is tuple of 4 floats, rgba
    float4 color = shaderTexture.Sample(samplerState, tex);

    // Read the color value at some offset, will be used as shadow
    float4 ocolor = shaderTexture.Sample(samplerState, tex+2.0*Scale*float2(-1.0, -1.0)/Resolution.y);

    // Thickness of raster
    const float thickness = 0.1;

    float ny = floor(tex.y/thickness);
    float my = tex.y%thickness;
    const float pi = 3.141592654;


    // ny is used to compute the rasterbar base color
    float cola = ny*2.0*pi;
    float3 col = 0.75+0.25*float3(sin(cola*0.111), sin(cola*0.222), sin(cola*0.333));

    // my is used to compute the rasterbar brightness
    //  smoothstep is a great little function: https://en.wikipedia.org/wiki/Smoothstep
    float brightness = 1.0-smoothstep(0.0, thickness*0.5, abs(my - 0.5*thickness));

    float3 rasterColor = col*brightness;

    // lerp(x, y, a) is another very useful function: https://en.wikipedia.org/wiki/Linear_interpolation
    float3 final = rasterColor;
    // Create the drop shadow of the terminal graphics
    //  .w is the alpha channel, 0 is fully transparent and 1 is fully opaque
    final = lerp(final, float(0.0), ocolor.w);
    // Draw the terminal graphics
    final = lerp(final, color.xyz, color.w);

    // Return the final color, set alpha to 1 (ie opaque)
    return float4(final, 1.0);
}

@lhecker
Copy link
Member

lhecker commented Mar 10, 2022

Are you 100% sure? 😅

image

You did reload the tab after disabling AtlasEngine / the experimental text renderer right?

@USLTD
Copy link
Author

USLTD commented Mar 10, 2022

I even reopened it

@USLTD
Copy link
Author

USLTD commented Mar 10, 2022

What's your settings,json?

@USLTD
Copy link
Author

USLTD commented Mar 10, 2022

Oh and I am using Preview version by the way

@lhecker
Copy link
Member

lhecker commented Mar 10, 2022

What's your settings,json?

I'm using your settings.json and the same Windows Terminal version (1.13.10336.0).

@USLTD
Copy link
Author

USLTD commented Mar 11, 2022

I solved issue by switching to Software Rendering instead of Hardware Rendering

@USLTD USLTD closed this as completed Mar 11, 2022
@ghost ghost added the Needs-Tag-Fix Doesn't match tag requirements label Mar 11, 2022
@lhecker
Copy link
Member

lhecker commented Mar 11, 2022

I solved issue by switching to Software Rendering instead of Hardware Rendering

This is interesting actually. Can you tell us more about the hardware you use? What's your CPU and GPU? Do you use Windows Terminal via a Virtual Machine, Remote Desktop, or some other mechanism?
This shouldn't happen and we should try and fix your issue. 🙂

If you have the time and would like to investigate (really just in case), could you enable hardware rendering again and download DebugView and see if any logs come up when you start Windows Terminal ("WT")? If you go into your start menu and search for dxcpl.exe you can find a tool that can enable DirectX debugging for WT. Here's how to use it:

image

If you're done debugging, don't forget to "Clear" the "Executable List". You need to click "Apply" (or "OK") in the primary window in order for the change to take effect.

All of that is just in case you have the time and interest in investigating this of course. 🙂

@USLTD
Copy link
Author

USLTD commented Mar 11, 2022

@lhecker I will upload details later when I will have time. For now I will enjoy CRT shader that I always wanted (since cool-retro-term)
Edit: CRT shader is super slow due Software Rendering 😭. Only option is Retro

@USLTD USLTD reopened this Mar 11, 2022
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Mar 11, 2022
@USLTD USLTD closed this as completed Mar 11, 2022
@ghost ghost added the Needs-Tag-Fix Doesn't match tag requirements label Mar 11, 2022
@USLTD
Copy link
Author

USLTD commented Mar 11, 2022

@lhecker
OK, here are the details:

WTPreviewHardwareRendering.LOG

@USLTD
Copy link
Author

USLTD commented Mar 11, 2022

And as I mentioned HLSL rendering works only with Software Rendering with both Preview and Stable versions

@lhecker
Copy link
Member

lhecker commented Mar 11, 2022

Found it:

00000232	1.32877946	[8336] D3D11 ERROR: ID3D11Device::CreateVertexShader: Shader must be vs_4_0. Shader version provided: vs_5_0 [ STATE_CREATION ERROR #167: CREATEVERTEXSHADER_INVALIDSHADERTYPE]	

Your GPU only supports feature level 10.0 for DirectX, which only apparently supports HLSL 4.0.

@lhecker lhecker reopened this Mar 11, 2022
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Mar 11, 2022
@lhecker
Copy link
Member

lhecker commented Mar 12, 2022

@UltraStudioLTD I've fixed the issue and will submit a pull request soon. Thank you for your great help! The log file you sent me immediately helped me find and fix the issue. 🙂

Unfortunately we're likely "soon" (next year?) dropping support for hardware-acceleration for hardware below feature level 10_1 and your GPU only has 10_0. I know it sounds presumptuous, but I would suggest seeing if you can get a GPU with DirectX 10_1 or 11_0 support somehow. For NVIDIA GPUs these include the GT 2xx (10_1), GT 4xx (11_0), or newer cards.
Of course Windows Terminal will continue to work on your hardware, but the performance will be rather poor as it will fall back to a software renderer called WARP. It won't be as poor as with the "software rendering" you enabled, but it'll still be significantly worse than an actual GPU.

@ghost ghost added the In-PR This issue has a related PR label Mar 12, 2022
@USLTD
Copy link
Author

USLTD commented Mar 12, 2022

@lhecker Well, by looks it would be better to upgrade/replace my entire PC since every card and board, including motherboard is very old and not compatible with new cards 😭. Well, thanks for fixing issue 👍
I never thought that just a single digit difference would be such a huge problem (10_0 and 10_1)

@ghost ghost closed this as completed in #12677 Mar 15, 2022
@ghost ghost removed the In-PR This issue has a related PR label Mar 15, 2022
ghost pushed a commit that referenced this issue Mar 15, 2022
* Drop engine support for DirectX 9.1
  Practically no one has such old hardware anymore and AtlasEngine additionally
  drops support for 10.0. The fallback also didn't work properly,
  because the `FeatureLevels` array failed to include 9.2 and 9.3.
  We'll simply fall back to WARP on all such devices.
* Optimize shaders during compilation
  The two new flags increase shader performance sometimes significantly.
* Fix shader feature level flags
  D3D feature level 10.0 only support 4.0 and 10.1 only 4.1 shaders.

## PR Checklist
* [x] Closes #12655
* [x] I work here
* [x] Tests added/passed

## Validation Steps Performed
* Add `WindowsTerminal.exe` in `dxcpl.exe`
* Add a basic `experimental.pixelShaderPath`
* All forced feature levels between `9_1` and `11_1` render as expected ✅
@ghost ghost added the Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release. label Mar 15, 2022
DHowett pushed a commit that referenced this issue Mar 15, 2022
* Drop engine support for DirectX 9.1
  Practically no one has such old hardware anymore and AtlasEngine additionally
  drops support for 10.0. The fallback also didn't work properly,
  because the `FeatureLevels` array failed to include 9.2 and 9.3.
  We'll simply fall back to WARP on all such devices.
* Optimize shaders during compilation
  The two new flags increase shader performance sometimes significantly.
* Fix shader feature level flags
  D3D feature level 10.0 only support 4.0 and 10.1 only 4.1 shaders.

## PR Checklist
* [x] Closes #12655
* [x] I work here
* [x] Tests added/passed

## Validation Steps Performed
* Add `WindowsTerminal.exe` in `dxcpl.exe`
* Add a basic `experimental.pixelShaderPath`
* All forced feature levels between `9_1` and `11_1` render as expected ✅

(cherry picked from commit d5fb736)
DHowett pushed a commit that referenced this issue Mar 15, 2022
* Drop engine support for DirectX 9.1
  Practically no one has such old hardware anymore and AtlasEngine additionally
  drops support for 10.0. The fallback also didn't work properly,
  because the `FeatureLevels` array failed to include 9.2 and 9.3.
  We'll simply fall back to WARP on all such devices.
* Optimize shaders during compilation
  The two new flags increase shader performance sometimes significantly.
* Fix shader feature level flags
  D3D feature level 10.0 only support 4.0 and 10.1 only 4.1 shaders.

## PR Checklist
* [x] Closes #12655
* [x] I work here
* [x] Tests added/passed

## Validation Steps Performed
* Add `WindowsTerminal.exe` in `dxcpl.exe`
* Add a basic `experimental.pixelShaderPath`
* All forced feature levels between `9_1` and `11_1` render as expected ✅

(cherry picked from commit d5fb736)
@ghost
Copy link

ghost commented Apr 19, 2022

🎉This issue was addressed in #12677, which has now been successfully released as Windows Terminal v1.12.1098.:tada:

Handy links:

@ghost
Copy link

ghost commented Apr 19, 2022

🎉This issue was addressed in #12677, which has now been successfully released as Windows Terminal Preview v1.13.1098.:tada:

Handy links:

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Rendering Text rendering, emoji, complex glyph & font-fallback issues Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-2 A description (P2) Product-Terminal The new Windows Terminal. Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants