Thursday, October 17, 2019

multidimensional arrays in C on heap

For future reference I have 3D arrays below as sample snippet

//want to work on a 3D array on the heap
//first lest get a single then a 2D array working correctly on the heap

#define IMAGE_WIDTH 4
#define IMAGE_HEIGHT 3
#define CHANNELS 2

void experiment6()
int* array1D = NULL;
int* array2D = NULL;
int* array3D = NULL;

array1D = (int*)malloc(IMAGE_WIDTH * sizeof(int));
for (int i = 0; i < IMAGE_WIDTH; i++)
array1D[i] = i;
for (int i = 0; i < IMAGE_WIDTH; i++)
printf("[%d]=%d ",i, array1D[i]);


array2D = (int*)malloc(IMAGE_WIDTH * IMAGE_HEIGHT * sizeof(int));
for (int i = 0; i < IMAGE_HEIGHT; i++)
for (int j = 0; j < IMAGE_WIDTH;j++)
array2D[i * IMAGE_WIDTH + j ] = i * IMAGE_WIDTH + j;
for (int i = 0; i < IMAGE_HEIGHT; i++)
for (int j = 0; j < IMAGE_WIDTH; j++)
printf("[%d]=%d ", i * IMAGE_WIDTH + j, array2D[i * IMAGE_WIDTH + j]);

array3D = (int*)malloc(IMAGE_WIDTH * IMAGE_HEIGHT * CHANNELS * sizeof(int));
for (int i = 0; i < IMAGE_HEIGHT; i++)
for (int j = 0; j < IMAGE_WIDTH; j++)
for (int k = 0; k < CHANNELS; k++)
array3D[(i* IMAGE_WIDTH * CHANNELS) + (CHANNELS*j) + k] = (i * IMAGE_WIDTH  * CHANNELS) + (CHANNELS * j) + k;
//printf("%d ", i * IMAGE_WIDTH * CHANNELS + CHANNELS*j + k);


for (int i = 0; i < IMAGE_HEIGHT; i++)
for (int j = 0; j < IMAGE_WIDTH; j++)
for (int k = 0; k < CHANNELS; k++)
// array2D[(i * IMAGE_WIDTH  CHANNELS) + (CHANNELS * j) + k] = (i * IMAGE_WIDTH * CHANNELS) + (CHANNELS * j) + k;
printf("[%d] = %d ", i * IMAGE_WIDTH * CHANNELS + CHANNELS*j + k, array3D[(i * IMAGE_WIDTH * CHANNELS) + (CHANNELS * j) + k]);

if (array1D != NULL) 
if (array2D != NULL)
if (array3D != NULL)


Monday, October 14, 2019

git (gitlab) windows password reset not propagated correctly

After you change your password, this doesn't propagate to the windows credential manager passwords. I went and manually modified each one and that seems to work.

Monday, October 07, 2019

debugging with symbols (VTune)

good article here:

I used this syntax:

looks like it worked.

This article makes you think you can get nvidia symbols, but you can't if you read it carefully. They are just using that server to allow retroactive driver binaries to be pulled.

Tuesday, August 27, 2019

vsync enable/disable

type: nvidia control panel, find vsync

Friday, August 09, 2019

Unsigned Shader Code

If you get this error:

D3D12 WARNING: ID3D12ShaderBytecode::CreatePipelineState: Shader is corrupt or in an unrecognized format, or is not signed. Ensure that DXIL.dll is used to sign the shader. This shader and PSO containing it will not be validated. [ EXECUTION WARNING #1243: NON_RETAIL_SHADER_MODEL_WONT_VALIDATE]

Head over here to Graham Wihlidal's blog to understand:

Note this is not going to help if you are trying to compile a (for example) 6.4 shader on a platform that does not yet support 6.4. This is probably a good thing.

Tuesday, June 25, 2019

Making a DX12 'Hello World' Starting Point from D3D2HelloWorld Samples

To create a very basic starting point DX12 Visual Studio based on the D3D12 Samples SDK codebase (branching from friendly developer license code as starting point):

Update for Visual Studio 2019:

  • create an x64 project, unicode looks like default
  • didn't need the win32 preprocessor defn below.
  • did need the libs
  • did need to change the subystem to windows
  • did need to disable shaders.hlsl compilation

Visual Studio 2017
Create a console application (File->New Project->Empty Project)
Pull in .cpp, .c, and .hlsl files from D3DFramebuffer (my feeling is this is the best base case due to correct render loop that does not block on previous frames Present call before starting to build command list for next frame).

Changed to an x64 build environment
On the project, walked the 'full compiler options' and the 'full linker options'

  1. Change character set to unicode from multibyte
  2. Add  'WIN32' to preprocessor definitions


  1. Add d3d12.lib, d3dcompiler.lib, and dxgi.lib to the set of files to link to
  2. Change subsystem to  'Windows' 
  3. Disabled compilation of shaders.hlsl by Visual studio

Change the lines that compile the shaders from this:
 ThrowIfFailed(D3DCompileFromFile(GetAssetFullPath(L"shaders.hlsl").c_str(), nullptr, nullptr, "VSMain", "vs_5_0", compileFlags, 0, &vertexShader, nullptr));
 ThrowIfFailed(D3DCompileFromFile(GetAssetFullPath(L"shaders.hlsl").c_str(), nullptr, nullptr, "PSMain", "ps_5_0", compileFlags, 0, &pixelShader, nullptr));
To this:
ThrowIfFailed(D3DCompileFromFile(L"shaders.hlsl", nullptr, nullptr, "VSMain", "vs_5_0", compileFlags, 0, &vertexShader, nullptr));
ThrowIfFailed(D3DCompileFromFile(L"shaders.hlsl", nullptr, nullptr, "PSMain", "ps_5_0", compileFlags, 0, &pixelShader, nullptr));

Note: I am sure GetAssetFullPath is useful, probably esp. in remote debug cases. Will circle back to this later.

imgui for DX12 hints

command line, in a visual studio window, builds the .objs but does not create a .exe. Did not resolve.

was able to pull in the project for the visual studio solution into the main solution for the imgui project. i used that to create build the project. i got a runtime error on line 384:

    // Store our identifier
//    static_assert(sizeof(ImTextureID) >= sizeof(g_hFontSrvGpuDescHandle.ptr), "Can't pack descriptor handle into TexID, 32-bit not supported yet.");

commented this out to get the basic sample running and it did not crash.

useful to at least investigate/learn more about imgui with DX12

Sunday, June 02, 2019

Sinus infection doctor recommendations

aleve/advil X
mucinex X
sudafed X X (don't take after 3pm)
clariten X X (via 24hr version)
nedi pot

Friday, April 26, 2019

Movie Maker paths for projects

Wow....they think this is secret...impossible to find via the GUI. It will be something like this:


Sunday, March 31, 2019

Building UE4 and a .NET error

Building UE4 and got an error about .NET. instead of tracking down a .NET specific issue, resolution was to update my Visual Studio and include the .NET tools. Not doing whatever the long winded stack overflow comments suggested.

Tuesday, March 12, 2019

Driver Reset in Windows

Got all choked up on your driver? try this: ctrl-shift-windows+b

ack to Marissa Du Bois for the pointer.

Wednesday, March 06, 2019

French Toast Recipe

French toast recipe

8 eggs
1 and 1/3 cup of milk
Vanilla to taste (I use ~1.5 ozs IIRC) Too little and you won't taste it. Too much and you get too much vanilla. Can also try almond syrup.
1 Lovejoy Bakeries Brioche loaf

Mix together the above ingredients.

Cut brioche loaf into 8 slices. You will have the ends left over. Also each slice is about as thick as the diameter of a nickel, then just pitch the ends or use them for something else. Don't try to make more slices because you won't have enough batter for good coverage.

Dip each piece of bread for 10 seconds on each side into the bowl.

Using a cookie sheet, lay out each piece to let the batter soak in.

Take the rest of the leftover batter and pour it over the pieces especially in spots that look like they need it. 

Wait 20 minutes, then flip over each piece and wait another 20 minutes. This ensures gravity has a chance to work on both sides.

Cook on a griddle at between 325 and 350 degrees for 3 minutes on each side.

Serve with toppings of choice. 

Tuesday, February 12, 2019

FLOPS of consoles over time...

Ack to Darrel Palke for the link:

Sunday, February 03, 2019

MBP stability with 3 external displays

Not totally root caused, but making this note to myself: When attaching a 3rd external 4k display I was able to get it to work but came home from dinner after entire rebuild and hours (not days) of stability to a BSOD. Rebooting and it seems that 3rd external display seems to wreak havoc. Went back to 2 external and using the laptop display for still 3 total. Recall the reason for my entire rebuild was when pulling out the same 4k display adapter that cause me to lose audio and Skype abilities....just deciding to stay away from a 3rd external display for now. Not worth the issues ATM.

Maybe total video bandwidth issues? Working past thermal limits where there wasn't adequate testing of drivers?  Cheap external 4k display? Cheap external adapters from USB-C to DP and/or HDMI (both seemed to create problems).

no time to root cause, solved the problem short term and moved on.

update: 2/11/19, stable after one week by going to the 2 external+laptop display vs. the 3 external.

Wednesday, January 23, 2019

reboot for unsigned drivers


realize new 'advanced options menu' you need to select 'see more options' to get to the Startup Settings' unlike the description above.