Results 1 to 4 of 4

Thread: compiling shaders

  1. #1
    Legendary Member NecroDOME's Avatar
    Join Date
    Mar 2004
    Location
    The Netherlands, Eindhoven
    Posts
    1,059

    compiling shaders

    I cant compile a shader, error message: error X3501: 'main': entrypoint not found

    Delphi caode (Code is a valid string, I checked in the debugger)
    [pascal]
    if Failed(D3DXCompileShader(PChar(Code), SizeOf(Code)-1, nil, nil, 'main',
    PChar(Profile), 0, @pCode, @pErrors, @ConstantTable)) then
    begin
    if LogErrors then
    begin
    Log('Error compiling vertex shader '+Profile);
    Log(PChar(pErrors.GetBufferPointer));
    end;
    Errors := PChar(pErrors.GetBufferPointer);
    Exit;
    end;
    [/pascal]

    Shader code:
    Code:
    float4x4 World : register(c0);
    float4x4 View : register(c4);
    float4x4 Proj : register(c8);
    
    struct VS_OUTPUT
    {
        float4 Pos				: POSITION;
        float4 Diffuse			: COLOR0;
    	float2 Tex              : TEXCOORD0;
    };
    
    struct VS_INPUT
    {
        float3 Pos              : POSITION;
    	float3 Normal           : NORMAL;
        float2 Tex              : TEXCOORD0;
    };
    
    VS_OUTPUT main(const VS_INPUT Input)
    {
    	float3 Pos = mul(float4(Input.Pos, 1), World);
    
    	Pos = mul(float4(Pos, 1), (float4x3)View);
    
    	VS_OUTPUT Out;
        Out.Pos = mul(float4(Pos, 1), Proj);
    	Out.Diffuse = float4(1, 1, 1, 1);
    	Out.Tex = Input.Tex;
        return Out;
    }
    Maybe we need to write a pascal interpeter so we can write shaders in pascal
    NecroSOFT - End of line -

  2. #2

    compiling shaders

    Is Code an array of characters or a string? If it is a string, then you should use Length instead of SizeOf:
    [pascal]
    if Failed(D3DXCompileShader(PChar(Code), Length(Code), nil, nil,
    PChar('main'), PChar(Profile), 0, @pCode, @pErrors,
    @ConstantTable)) then ...
    [/pascal]
    I am not sure about the rest of parameters though, since I am using effect files instead of writing shaders separately. ops:

    Also, is there a reason to use three separate matrix multiplications in your shader code for each vertex?

    You can use only one multiplication by premultiplying all three matrices and then using something like this:
    Code:
    // The result of World * View * Projection matrix multiplication
    float4x4 g_mWVP : register(c0); 
    
    struct VS_OUTPUT 
    { 
      float4 Pos     : POSITION; 
      float4 Diffuse : COLOR0; 
      float2 Tex     : TEXCOORD0; 
    }; 
    
    struct VS_INPUT 
    { 
      float3 Pos    : POSITION; 
      float3 Normal : NORMAL; 
      float2 Tex    : TEXCOORD0; 
    }; 
    
    VS_OUTPUT main(const VS_INPUT Input) 
    { 
      VS_OUTPUT Out = (VS_OUTPUT)0;
    
      Out.Pos = mul(float4(Input.Pos, 1.0f), g_mWVP);
      Out.Tex = Input.Tex;
    
      return Out;
    }

  3. #3

    compiling shaders

    everything compiled:
    Code:
      D3DXCompileShader(
        PChar(Memo1.Text),
        length(Memo1.Text),
        nil, nil,
        'main',
        'vs_1_1',
        0,
        @ShaderBuffer,
        @ErrorBuffer,
        @ConstantTable
      );
    As Lifepower said it's probably SizeOf(Code)-1 that was causing the problem.

  4. #4
    Legendary Member NecroDOME's Avatar
    Join Date
    Mar 2004
    Location
    The Netherlands, Eindhoven
    Posts
    1,059

    compiling shaders

    Thanx, it worked... i was looking elsewhere for the error... (and thx to lifepower )
    NecroSOFT - End of line -

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •