Monday, April 8, 2019

What version of DirectX api or version the game application is using, while it's running?

Do you wonder what DX version or api your game/graphics application is using and you have no clue how to check it?

Here is the way,
1. Download Process explorer 
2. Launch Process Explorer > View > Lower Pane View > DLLs. 
3. Run your game, switch back to Process Explorer, and select executable of your application.
4. Look which libraries it has loaded. 
For DX11, library will d3d11.dll and for dx12 its d3d12.dll.

Thank you.

Wednesday, February 1, 2017

Perfmon error- Performance Counter Input string was not in a correct format C#

Issue:


Here is my code
float cpuLoad = 0;

try{
    MessageBox.Show("Running");

    //CPU Load
    PerformanceCounter cpuCounter = new PerformanceCounter();
    cpuCounter.CategoryName = "Processor";
    cpuCounter.CounterName = "% Processor Time";
    cpuCounter.InstanceName = "_Total";

    MessageBox.Show("Performance Counter Created");

    cpuLoad = cpuCounter.NextValue(); // Here exception is raised
}
catch(Exception ex) { MessageBox.Show(ex.Message); }
I have a try and catch around it and here is the exception it throws Input string was not in a correct format.

Solution:
try in cmd> lodctr /r
If above command is successful then all of your issues related to perfmon are resolved.
In case above command is not successful then try following:
Open perfmon-> Go to File-> Options-> Delete store files.
Now again try "lodctr /r". This should work now.

Monday, March 31, 2014

Access "System Volume Information" folder

In cmd, type the following and press enter:
cmd> cacls "driveletter:\System Volume Information" /E /G username:F

Ex.
C:\>cacls "c:\System Volume Information" /E /G Administrator:F

To remove access:
cacls "driveletter:\System Volume Information" /E /R username

Monday, December 16, 2013

Want to use DataSet and Linq to read XML?

Here is a small example on how to use DataSet and Linq to read XML. It may be helpful when dealing with small and large schema XML.

Example:
1.        
XML schema:
<Main>
  <Node1 Name="Test1" Attrib1="Attrib1Value" Attrib2="Attrib2Value"></Node1>
  <Node1 Name="Test2" Attrib1="Attrib1Value" Attrib2="Attrib2Value"></Node1>
  <Node1 Name="Test3" Attrib1="Attrib1Value" Attrib2="Attrib2Value"></Node1>
</Main>

Virtual Data Table representation (Each unique node represented as a table and same kind of nodes as its rows with columns representing attributes):
Table Name: Node1
Node1_ID
Name
Attrib1
Attrib1
0
Test1
Attrib1Value
Attrib2Value
1
Test2
Attrib1Value
Attrib2Value
2
Test3
Attrib1Value
Attrib2Value

C# code to access and query data from above XML:
            string xmlfile = @"Example_1.xml";
            DataSet dataSet = new DataSet();
            dataSet.ReadXml(xmlfile);

            DataTable node1Table = dataSet.Tables["Node1"];//Read XML node named = Node1
            string testName = "Test1";
            var query = from table in node1Table.AsEnumerable()
                        where table.Field<string>("Name").Equals(testName) //Selection criteria
                        select new
                        {
                                    //Return values
                                name = table.Field<string>("Name"),
                                attribVal1 = table.Field<string>("Attrib1"),
                                attribVal2 = table.Field<string>("Attrib2")
                        };

            //Print output
            foreach (var result in query)
            {
                Console.WriteLine("Name = " + result.name);
                Console.WriteLine("Attrib1 = " + result.attribVal1);
                Console.WriteLine("Attrib2 = " + result.attribVal2);
            }

Output:
Name = Test1
Attrib1 = Attrib1Value
Attrib2 = Attrib2Value
----------------------------


2.       Example:
XML:
<ApicOnlyGamesInfo>
  <TestInfo Test="Battlefield 3 - DirectX 11- Lighting Effect (Automation)" GameName="BattleField3" DxVersion="DX11" email="vgoel@nvidia.com">
    <NvCplSettingInfo Name="" Value=""/>
    <ApicTraceInfo GoldenImagePath="ApicOnlyGames\BF3\2560x1600\Lighting_Comrades" ApicPlayeName="d3d11_replayer.exe" PixellDiff="1000" Fuzz="5">
      <XP TraceSourcePath="ApicOnlyGames\APIC\BF3\COMRADES\Lighting\2560x1600" />
      <WIN7 TraceSourcePath="ApicOnlyGames\APIC\BF3\COMRADES\Lighting\2560x1600" />
      <WIN8 TraceSourcePath="ApicOnlyGames\APIC\BF3\COMRADES\Lighting\2560x1600" />
      <WINBLUE TraceSourcePath="ApicOnlyGames\APIC\BF3\COMRADES\Lighting\2560x1600" />
    </ApicTraceInfo>
    <ApicTraceInfo GoldenImagePath="ApicOnlyGames\BF3\2560x1600\Lighting_Operation_GUILLOTINE" ApicPlayeName="d3d11_replayer.exe" PixellDiff="1000" Fuzz="5">
      <XP TraceSourcePath="ApicOnlyGames\APIC\BF3\Operation_GUILLOTINE\Lighting\2560x1600" />
      <WIN7 TraceSourcePath="ApicOnlyGames\APIC\BF3\Operation_GUILLOTINE\Lighting\2560x1600" />
      <WIN8 TraceSourcePath="ApicOnlyGames\APIC\BF3\Operation_GUILLOTINE\Lighting\2560x1600" />
      <WINBLUE TraceSourcePath="ApicOnlyGames\APIC\BF3\Operation_GUILLOTINE\Lighting\2560x1600" />
    </ApicTraceInfo>
    <ApicTraceInfo GoldenImagePath="ApicOnlyGames\BF3\2560x1600\Lighting_SEMPER_FIDELIS" ApicPlayeName="d3d11_replayer.exe" PixellDiff="1000" Fuzz="5">
      <XP TraceSourcePath="ApicOnlyGames\APIC\BF3\SEMPER_FIDELIS\Lighting\2560x1600" />
      <WIN7 TraceSourcePath="ApicOnlyGames\APIC\BF3\SEMPER_FIDELIS\Lighting\2560x1600" />
      <WIN8 TraceSourcePath="ApicOnlyGames\APIC\BF3\SEMPER_FIDELIS\Lighting\2560x1600" />
      <WINBLUE TraceSourcePath="ApicOnlyGames\APIC\BF3\SEMPER_FIDELIS\Lighting\2560x1600" />
    </ApicTraceInfo>
  </TestInfo>
 
  <TestInfo Test="Battlefield 3 - DirectX 11- Shadows (Automation)" GameName="BattleField3" DxVersion="DX11" email="vgoel@nvidia.com">
    <NvCplSettingInfo Name="" Value=""/>   
    <ApicTraceInfo GoldenImagePath="ApicOnlyGames\BF3\2560x1600\Shadows_Operation_GUILLOTINE" ApicPlayeName="d3d11_replayer.exe" PixellDiff="1000" Fuzz="5">
      <XP TraceSourcePath="ApicOnlyGames\APIC\BF3\Operation_GUILLOTINE\Shadows\2560x1600" />
      <WIN7 TraceSourcePath="ApicOnlyGames\APIC\BF3\Operation_GUILLOTINE\Shadows\2560x1600" />
      <WIN8 TraceSourcePath="ApicOnlyGames\APIC\BF3\Operation_GUILLOTINE\Shadows\2560x1600" />
      <WINBLUE TraceSourcePath="ApicOnlyGames\APIC\BF3\Operation_GUILLOTINE\Shadows\2560x1600" />
    </ApicTraceInfo>
    <ApicTraceInfo GoldenImagePath="ApicOnlyGames\BF3\2560x1600\Shadows_SEMPER_FIDELIS" ApicPlayeName="d3d11_replayer.exe" PixellDiff="1000" Fuzz="5">
      <XP TraceSourcePath="ApicOnlyGames\APIC\BF3\SEMPER_FIDELIS\Shadows\2560x1600" />
      <WIN7 TraceSourcePath="ApicOnlyGames\APIC\BF3\SEMPER_FIDELIS\Shadows\2560x1600" />
      <WIN8 TraceSourcePath="ApicOnlyGames\APIC\BF3\SEMPER_FIDELIS\Shadows\2560x1600" />
      <WINBLUE TraceSourcePath="ApicOnlyGames\APIC\BF3\SEMPER_FIDELIS\Shadows\2560x1600" />
    </ApicTraceInfo>
  </TestInfo>
</ApicOnlyGamesInfo>

Virtual Data Table Representation (Each unique node represented as a table and same kind of nodes as its rows with columns representing attributes):
     
      Table: TestInfo
TestInfo_ID
Test
GameName
DxVersion
email
0
Battlefield 3 - DirectX 11- Lighting Effect (Automation)
BattleField3
DX11
1
Battlefield 3 - DirectX 11- Shadows (Automation)
BattleField3
DX11

      Table: ApicTraceInfo
TestInfo_ID
ApicTraceInfo_ID
GoldenImagePath
ApicPlayeName
PixellDiff
Fuzz
0
0
ApicOnlyGames\BF3\2560x1600\Lighting_Comrades
d3d11_replayer.exe
1000
5
0
1
ApicOnlyGames\BF3\2560x1600\Lighting_Operation_GUILLOTINE
d3d11_replayer.exe
1000
5
0
2
ApicOnlyGames\BF3\2560x1600\Lighting_SEMPER_FIDELIS
d3d11_replayer.exe
1000
5
1
3
ApicOnlyGames\BF3\2560x1600\Shadows_Operation_GUILLOTINE
d3d11_replayer.exe
1000
5
1
4
ApicOnlyGames\BF3\2560x1600\Shadows_SEMPER_FIDELIS
d3d11_replayer.exe
1000
5

      Table: XP
ApicTraceInfo_ID
XP_ID
TraceSourcePath
0
0
ApicOnlyGames\APIC\BF3\COMRADES\Lighting\2560x1600
1
1
ApicOnlyGames\APIC\BF3\Operation_GUILLOTINE\Lighting\2560x1600
2
2
ApicOnlyGames\APIC\BF3\SEMPER_FIDELIS\Lighting\2560x1600
3
3
ApicOnlyGames\APIC\BF3\Operation_GUILLOTINE\Shadows\2560x1600
4
4
ApicOnlyGames\APIC\BF3\SEMPER_FIDELIS\Shadows\2560x1600

Similarly there will be tables for WIN7/WIN8 and WINBLUE as well.

C# code to access and query from above xml (Get TraceSourcePath from each ApicTraceInfo for matching TestInfo->Test):
string xmlFile = @"C:\Perforce\sw\qa\AtpTestcases\GamesAutomation\ApicOnlyGames\ApicOnlyGamesInputData.xml";
            DataSet dataSet = new DataSet();
            dataSet.ReadXml(xmlFile);

            DataTable testInfo = dataSet.Tables["TestInfo"];
            DataTable apicTraceInfo = dataSet.Tables["ApicTraceInfo"];
            DataTable os = dataSet.Tables[Detection.GetOS().Replace("32", "").Replace("64", "")];

            string testName = "Battlefield 3 - DirectX 11- Shadows (Automation)";
            var query = from test in testInfo.AsEnumerable()
                        join traceInfo in apicTraceInfo.AsEnumerable()
                        on test.Field<int>("TestInfo_ID") equals
                        traceInfo.Field<int>("TestInfo_ID")
                        join osNode in os.AsEnumerable()
                        on traceInfo.Field<int>("ApicTraceInfo_ID") equals
                        osNode.Field<int>("ApicTraceInfo_ID")
                        where test.Field<string>("Test").Equals(testName)//Selection criteria
                        select new
                        {
                              //Return values
                            Test = test.Field<string>("Test"),
                            GoldenPath = traceInfo.Field<string>("GoldenImagePath"),
                            tracePath = osNode.Field<string>("TraceSourcePath")
                        };

            //Print output
            foreach (var res in query)
            {
                Console.WriteLine("Test Name: " + res.Test);
                Console.WriteLine("GoldenPath: " + res.GoldenPath);
                Console.WriteLine("Trace Path : " + res.tracePath);
      }

Output:
Test Name: Battlefield 3 - DirectX 11- Shadows (Automation)
GoldenPath: ApicOnlyGames\BF3\2560x1600\Shadows_Operation_GUILLOTINE
Trace Path : ApicOnlyGames\APIC\BF3\Operation_GUILLOTINE\Shadows\2560x1600
Test Name: Battlefield 3 - DirectX 11- Shadows (Automation)
GoldenPath: ApicOnlyGames\BF3\2560x1600\Shadows_SEMPER_FIDELIS
Trace Path : ApicOnlyGames\APIC\BF3\SEMPER_FIDELIS\Shadows\2560x1600

--------------------------------------------------------------------------------------------------------