Browse Source

* fixed some small bugs

master
Bergmann89 9 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 protected
procedure LogMsgIntern(const aSender: TengShaderPart; const aLogLevel: TengShaderPartLogLevel; const aMsg: String); override; procedure LogMsgIntern(const aSender: TengShaderPart; const aLogLevel: TengShaderPartLogLevel; const aMsg: String); override;
public 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 GeneratorNames[const aIndex: Integer]: String read GetGeneratorNames;
property GeneratorCount: Integer read GetGeneratorCount; property GeneratorCount: Integer read GetGeneratorCount;
property OnLog: TengShaderFileLogEvent read fOnLog write fOnLog; property OnLog: TengShaderFileLogEvent read fOnLog write fOnLog;
@@ -239,8 +239,10 @@ begin
ms := TMemoryStream.Create; ms := TMemoryStream.Create;
walker := TengSearchWalker.Create(sr); walker := TengSearchWalker.Create(sr);
try 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 for i := 0 to sr.Count-1 do
(sr[i] as TengShaderPartInclude).SaveToFile(aFilename, aFileWriter); (sr[i] as TengShaderPartInclude).SaveToFile(aFilename, aFileWriter);
sl.Text := Text; sl.Text := Text;


+ 2
- 0
uengShaderFileTypes.pas View File

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


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


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


+ 41
- 5
uengShaderGenerator.pas View File

@@ -35,6 +35,10 @@ type
property PropertyNames [const aIndex: Integer]: String read GetPropertyNames; property PropertyNames [const aIndex: Integer]: String read GetPropertyNames;
property PropertyCount: Integer read GetPropertyCount; 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 } { Generate Shader Code }
public public
procedure GenerateCode(const aCode: TengShaderCode); procedure GenerateCode(const aCode: TengShaderCode);
@@ -152,6 +156,38 @@ begin
UpdateProperties; UpdateProperties;
end; 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); procedure TengShaderGenerator.GenerateCode(const aCode: TengShaderCode);
var var
@@ -185,17 +221,17 @@ begin
args.PopFlags; args.PopFlags;
end; end;
end; end;

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


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

args.PushCode; args.PushCode;
try try
args.GenerateMetaCode; args.GenerateMetaCode;


+ 2
- 1
uengShaderPartInclude.pas View File

@@ -106,7 +106,8 @@ end;
procedure TengShaderPartInclude.SaveToFile(const aFilename: String; const aFileWriter: IengShaderFileWriter); procedure TengShaderPartInclude.SaveToFile(const aFilename: String; const aFileWriter: IengShaderFileWriter);
begin begin
LoadShaderFile; 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; fAbsoluteFile := ExtractFilePath(aFilename) + fIncludeFile;
fShaderFile.SaveToFile(fAbsoluteFile, aFileWriter); fShaderFile.SaveToFile(fAbsoluteFile, aFileWriter);
end; end;


+ 1
- 1
uengShaderPartProc.pas View File

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


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


Loading…
Cancel
Save