Skip to content

Instantly share code, notes, and snippets.

View Cody-Duncan's full-sized avatar

Cody Duncan Cody-Duncan

  • Seattle, United States
  • 00:33 (UTC -08:00)
View GitHub Profile
def create_matrix(len_a, len_b):
matrix = [0] * (len_a+1)
for i in range(len_a+1):
matrix[i] = [0] * (len_b+1)
return matrix
def get_sequence_indices(matrix):
len_row = len(matrix)
len_col = len(matrix[0])
// ##### ComputeShader.hlsl #####
Texture2D TextureInput : register(t0); // Input texture to read from
RWTexture2D<float4> TextureOutput : register(u0); // Temp output
void main( uint3 DTid : SV_DispatchThreadID, uint3 groupID: SV_GroupID, uint3 groupThreadID: SV_GroupThreadID )
{
float4 vColor = TextureInput[int2(groupThreadID.x, groupID.y)];
// do stuff to vColor
// Store result
TextureOutput[int2(groupThreadID.x,groupID.y)]=vColor;
@Cody-Duncan
Cody-Duncan / gist:cea6c7d5c4abe369d6b6
Last active August 29, 2015 14:14
Typical Visual Studio PostBuild and Output Directory Settings
//PostBuild Event
// Copies .dll, .pdb, and .exe files from a directory named "dll" to output folder.
// Often, "dll" will be "lib", depending on where you put your .dll files.
// /F Display full source and destination file names while copying.
// /Y Suppress prompt to confirm overwriting a file.
// /D Copy only files whosesource date/time is newer than the destination time.
// $(SolutionDir) - Visual Studio Macro; the directory the project .sln file is located
// $(TargetDir) - Visual Studio Macro; the directory that the built executable is written to
xcopy "$(SolutionDir)dll\*.dll" "$(TargetDir)" /F /Y /D
@Cody-Duncan
Cody-Duncan / gist:df88c10b0e13cfe9734d
Created August 1, 2014 04:33
DirectX11 SetDebugObjectName Overloads and ReportLiveObjects
#pragma once
// If necessary, use this to free raw pointers.
// Preferably, use Microsoft::WRL::ComPtr from client.h (http://msdn.microsoft.com/en-us/library/br244983.aspx)
#ifndef SAFE_RELEASE
#define SAFE_RELEASE(x) \
if(x != NULL) \
{ \
x->Release(); \
x = NULL; \
@Cody-Duncan
Cody-Duncan / gist:d85740563ceea99f6619
Created August 1, 2014 04:30
DirectX11 Generate Input Layout from Vertex Shader using D3DReflect.
//Function Creates an input layout from the vertex shader, after compilation.
//Input layout can be reused with any vertex shaders that use the same input layout.
HRESULT CreateInputLayoutDescFromVertexShaderSignature( ID3DBlob* pShaderBlob, ID3D11Device* pD3DDevice, ID3D11InputLayout** pInputLayout, int* inputLayoutByteLength )
{
// Reflect shader info
ID3D11ShaderReflection* pVertexShaderReflection = nullptr;
HRESULT hr = S_OK;
if ( FAILED( D3DReflect( pShaderBlob->GetBufferPointer(), pShaderBlob->GetBufferSize(), IID_ID3D11ShaderReflection, (void**) &pVertexShaderReflection ) ) )
{