Browse Source

* fixed some small bugs

master
Bergmann89 8 years ago
parent
commit
2a53695264
5 changed files with 51 additions and 10 deletions
  1. +5
    -3
      uengShaderFile.pas
  2. +2
    -0
      uengShaderFileTypes.pas
  3. +41
    -5
      uengShaderGenerator.pas
  4. +2
    -1
      uengShaderPartInclude.pas
  5. +1
    -1
      uengShaderPartProc.pas

+ 5
- 3
uengShaderFile.pas View File

@@ -50,7 +50,7 @@ type
protected
procedure LogMsgIntern(const aSender: TengShaderPart; const aLogLevel: TengShaderPartLogLevel; const aMsg: String); override;
public
property Generator [const aName: String]: TengShaderGenerator read GetGenerator;
property Generator [const aName: String]: TengShaderGenerator read GetGenerator;
property GeneratorNames[const aIndex: Integer]: String read GetGeneratorNames;
property GeneratorCount: Integer read GetGeneratorCount;
property OnLog: TengShaderFileLogEvent read fOnLog write fOnLog;
@@ -239,8 +239,10 @@ begin
ms := TMemoryStream.Create;
walker := TengSearchWalker.Create(sr);
try
walker.SearchFlags := [sfSearchChildren];
walker.ResultTypes := CengShaderPartArr.Create(TengShaderPartInclude);
walker.SearchFlags := [sfSearchChildren];
walker.ChildrenDoNotLeave := CengShaderPartArr.Create(TengShaderFile);
walker.ResultTypes := CengShaderPartArr.Create(TengShaderPartInclude);
walker.Run(self);
for i := 0 to sr.Count-1 do
(sr[i] as TengShaderPartInclude).SaveToFile(aFilename, aFileWriter);
sl.Text := Text;


+ 2
- 0
uengShaderFileTypes.pas View File

@@ -222,6 +222,7 @@ implementation
uses
uengShaderPart;

{$IFNDEF SHADER_FILE_USE_BITSPACE_UTILS}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//TIntfObjNoRefCount//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -274,6 +275,7 @@ begin
FreeAndNil(fs);
end;
end;
{$ENDIF}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//TengMetaData//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


+ 41
- 5
uengShaderGenerator.pas View File

@@ -35,6 +35,10 @@ type
property PropertyNames [const aIndex: Integer]: String read GetPropertyNames;
property PropertyCount: Integer read GetPropertyCount;

function TryGetProperty(const aName: String; out aValue: Variant): Boolean;
function TrySetProperty(const aName: String; const aValue: Variant): Boolean;
procedure ListProperties(const aPropertyNames: TStrings);

{ Generate Shader Code }
public
procedure GenerateCode(const aCode: TengShaderCode);
@@ -152,6 +156,38 @@ begin
UpdateProperties;
end;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function TengShaderGenerator.TryGetProperty(const aName: String; out aValue: Variant): Boolean;
var
l: TengShaderPartPropertyList;
begin
l := fPropertyMap[aName];
result := Assigned(l);
if result
then aValue := l.Value
else aValue := unassigned;
end;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function TengShaderGenerator.TrySetProperty(const aName: String; const aValue: Variant): Boolean;
var
l: TengShaderPartPropertyList;
begin
l := fPropertyMap[aName];
result := Assigned(l);
if result then
l.Value := aValue;
end;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure TengShaderGenerator.ListProperties(const aPropertyNames: TStrings);
var
s: String;
begin
for s in fPropertyMap.Keys do
aPropertyNames.Add(s);
end;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure TengShaderGenerator.GenerateCode(const aCode: TengShaderCode);
var
@@ -185,17 +221,17 @@ begin
args.PopFlags;
end;
end;

args.GenerateProcedureCode;
args.GenerateParameterCode(CengShaderPartArr.Create(TengShaderPartVar));
args.GenerateParameterCode(CengShaderPartArr.Create(TengShaderPartVarying));
args.GenerateParameterCode(CengShaderPartArr.Create(TengShaderPartUniform));
finally
FreeAndNil(walker);
FreeAndNil(sr);
args.PopCode([pcfAppend, pcfAddEmptyLine]);
end;

args.GenerateProcedureCode;
args.GenerateParameterCode(CengShaderPartArr.Create(TengShaderPartVar));
args.GenerateParameterCode(CengShaderPartArr.Create(TengShaderPartVarying));
args.GenerateParameterCode(CengShaderPartArr.Create(TengShaderPartUniform));

args.PushCode;
try
args.GenerateMetaCode;


+ 2
- 1
uengShaderPartInclude.pas View File

@@ -106,7 +106,8 @@ end;
procedure TengShaderPartInclude.SaveToFile(const aFilename: String; const aFileWriter: IengShaderFileWriter);
begin
LoadShaderFile;
fIncludeFile := Format('%p_', [Pointer(fShaderFile)]) + ExtractFileName(fIncludeFile);
if (Pos('SFPF', ExtractFileName(fIncludeFile)) <> 1) then
fIncludeFile := Format('SFPF%p_', [Pointer(fShaderFile)]) + ExtractFileName(fIncludeFile);
fAbsoluteFile := ExtractFilePath(aFilename) + fIncludeFile;
fShaderFile.SaveToFile(fAbsoluteFile, aFileWriter);
end;


+ 1
- 1
uengShaderPartProc.pas View File

@@ -10,7 +10,7 @@ uses
uengShaderPart, uengShaderPartScope, uengShaderFileParser, uengShaderGeneratorArgs

{$IFDEF SHADER_FILE_USE_BITSPACE_UTILS}
, uutlGenerics;
, uutlGenerics
{$ELSE}
, uengShaderFileGenerics
{$ENDIF}


Loading…
Cancel
Save