Repository: microsoft/terminal
File: src/renderer/atlas/BackendD3D.cpp (C++)

Code before:
                    {
                        D3D11_SHADER_VARIABLE_DESC variableDescriptor;
                        if (SUCCEEDED(variableReflector->GetDesc(&variableDescriptor)))
                        {
                            // only if time is used
                            _requiresContinuousRedraw = WI_IsFlagSet(variableDescriptor.uFlags, D3D_SVF_USED);
                        }
                    }
                }
            }
            else
            {
                // Unless we can determine otherwise, assume this shader requires evaluation every frame
                _requiresContinuousRedraw = true;
            }
        }
        else
        {
            if (error)
            {
                LOG_HR_MSG(hr, "%.*hs", static_cast<int>(error->GetBufferSize()), static_cast<char*>(error->GetBufferPointer()));
                if (p.warningCallback)
                {
                    //to handle compile time errors
                    const char* errorMessage = static_cast<char*>(error->GetBufferPointer());
                    std::wstring errorMessageWString(errorMessage, errorMessage + strlen(errorMessage));
                    p.warningCallback(D2DERR_SHADER_COMPILE_FAILED, errorMessageWString);
                }
            }
            else
            {
                LOG_HR(hr);
                if (p.warningCallback)
                {
                    //to handle errors such as file not found, path not found, access denied
                    p.warningCallback(hr, p.s->misc->customPixelShaderPath);
                }
            }
        }

        if (!p.s->misc->customPixelShaderImagePath.empty())
        {
            try
            {
                WIC::LoadTextureFromFile(p.device.get(), p.s->misc->customPixelShaderImagePath.c_str(), _customShaderTexture.addressof(), _customShaderTextureView.addressof());
            }
            catch (...)
            {
                LOG_CAUGHT_EXCEPTION();
                _customPixelShader.reset();
                if (p.warningCallback)

Review comment (bug):
This isn't compatible with Unicode text. It effectively compiles down to a
```cpp
for (int i = 0; i < len; i++) {
    dst[i] = src[i];
}
```
In other words, it blindly casts the `char`s to `wchar_t`s.

Instead, add the following include to the top of the file:
```cpp
#include "../../types/inc/ColorFix.hpp" <-- already exists
#include "../../types/inc/convert.hpp"  <-- new
```

and use something like this:
```cpp
const std::string_view msgA{ static_cast<const char*>(error->GetBufferPointer()), error->GetBufferSize() };
const auto msgW = ConvertToW(CP_ACP, msgA);
```

After thinking about this for a bit, I think it's fine to remove the two `LOG_HR` calls. They don't really do anything anyway. So you'd basically end up with something like this?
```cpp
if (SUCCEEDED(hr))
{
    THROW_IF_FAILED(p.device->CreatePixelShader(blob->GetBufferPointer(), blob->GetBufferSize(), nullptr, _customPixelShader.addressof()));
    // ...
}
else if (p.warningCallback)
{
    if (error)
    {
        const std::string_view msgA{ static_cast<const char*>(error->GetBufferPointer()), error->GetBufferSize() };
        const auto msgW = ConvertToW(CP_ACP, msgA);
        p.warningCallback(D2DERR_SHADER_COMPILE_FAILED, msgW);
    }
    else
    {
        p.warningCallback(hr, p.s->misc->customPixelShaderPath);
    }
}
```

...or maybe something similar. Up to you! :)

Code after:
                    if (ID3D11ShaderReflectionVariable* variableReflector = constantBufferReflector->GetVariableByIndex(0)) // time
                    {
                        D3D11_SHADER_VARIABLE_DESC variableDescriptor;
                        if (SUCCEEDED(variableReflector->GetDesc(&variableDescriptor)))
                        {
                            // only if time is used
                            _requiresContinuousRedraw = WI_IsFlagSet(variableDescriptor.uFlags, D3D_SVF_USED);
                        }
                    }
                }
            }
            else
            {
                // Unless we can determine otherwise, assume this shader requires evaluation every frame
                _requiresContinuousRedraw = true;
            }
        }
        else
        {
            if (error)
            {
                if (p.warningCallback)
                {
                    //to handle compile time errors
                    const std::string_view errMsgStrView{ static_cast<const char*>(error->GetBufferPointer()), error->GetBufferSize() };
                    const auto errMsgWstring = ConvertToW(CP_ACP, errMsgStrView);
                    p.warningCallback(D2DERR_SHADER_COMPILE_FAILED, errMsgWstring);
                }
            }
            else
            {
                if (p.warningCallback)
                {
                    //to handle errors such as file not found, path not found, access denied
                    p.warningCallback(hr, p.s->misc->customPixelShaderPath);
                }
            }
        }

        if (!p.s->misc->customPixelShaderImagePath.empty())
        {
            try
            {
                WIC::LoadTextureFromFile(p.device.get(), p.s->misc->customPixelShaderImagePath.c_str(), _customShaderTexture.addressof(), _customShaderTextureView.addressof());
            }
            catch (...)
            {
                LOG_CAUGHT_EXCEPTION();
                _customPixelShader.reset();
                if (p.warningCallback)
                {