Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9192987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:03:28+00:00 2026-06-17T21:03:28+00:00

I am using fxc.exe utility from directx sdk to compile my shaders and then

  • 0

I am using fxc.exe utility from directx sdk to compile my shaders and then load them as byte array in my application (with this code):

inline std::vector<char> ReadToByteArray(char* filename)
    {
        std::ifstream file;
        file.open(filename);
        file.seekg(0, std::ios::end);
        size_t file_size = file.tellg();
        file.seekg(0, std::ios::beg);
        std::vector<char> data(file_size, 0);
        file.read(&data[0], file_size);

        return data;
    }

And then create it:

std::vector<char> pixelShaderBytecode = ReadToByteArray("myps.pso");
ID3D11PixelShader* shader;
device->CreatePixelShader(pixelShaderBytecode.data(), pixelShaderBytecode.size(), nullptr, &shader);

And all worked good. Until my shader had grown to ~980 bytes in size. Here is my code in HLSL:

struct PInput
{
    float4 position: SV_POSITION;
    float3 normal : NORMAL;
};

cbuffer CBuffer
{
    float4 color;
    float4 dirs[8];
};

float4 main(PInput input) : SV_TARGET
{
    // Example code...

    int directionLightsCount = 2;

    float intensity = 0.0f;

    // Line 1
    intensity += saturate(dot(input.normal, -dirs[0].xyz));

    // Line 2
    //intensity += saturate(dot(input.normal, -dirs[1].xyz));

    float ambient = 0.1f;

    return color * saturate(ambient + intensity);
}

Problem is, that if i will uncomment line 2, then i will get E_INVALIDARG HRESULT from ID3D11Device::CreatePixelShader method. And also warning from D3D11 debug layer:

D3D11 ERROR: ID3D11Device::CreatePixelShader: Pixel Shader is corrupt or in an unrecognized format. [ STATE_CREATION ERROR #192: CREATEPIXELSHADER_INVALIDSHADERBYTECODE]

If i will comment this line again, then all will work. If i will change them (0 index with 1) then all will work. The only difference i see – size of compiled file (980 with both lines, and 916 with just first line)

Here is the command with which i compile hlsl code:

C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Utilities\bin\x64>fxc /
T ps_5_0 /E "main" /Fo "ps.pso" ps.ps

What is the reason of this behavior? Am i missed something important?

Thanx for any help.

EDIT: Forgot to say, that both versions compiled without any errors. Also, vertex shader created without any problem (1400 bytes). I am using 11_0 feature level.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T21:03:29+00:00Added an answer on June 17, 2026 at 9:03 pm

    A simple error: wrong file reading…

    inline std::vector<char> ReadToByteArray(char* filename)
    {
        std::vector<char> data;
        std::ifstream file(filename, std::ios::in | std::ios::binary | std::ios::ate);
        data.resize(file.tellg());
        file.seekg(0, std::ios::beg);
        file.read(&data[0], data.size());
        return data;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using jQuery, how do I get the value from a textbox and then load
Using Trigger.io's barcode api in an application that only contains boilerplate HTML and the
Using Android NDK is it possible (from native C-code) to get a list of
Using JQuery,Is there any possible to capture images/scanned documents from digital Camera/Scanner Connected to
Using CMake I want to check if a particular function (cv::getGaborKernel) from OpenCV library
Using Visual C++ 2008. First time, I'm experimenting in crossing over from C# and
Using JAXB in Java it is easy to generate from a xml schema file
Using IOS, I am trying to integrate the LinkedIn into the application. The integration
Using the http://www.ifans.com/forums/showthread.php?t=132024 post from another question i am allowing the user to enter
Using the C# Facebook SDK 5.0.3 everything works fine whit the client.Get(/me). But when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.