This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "stdafx.h" | |
#include <unordered_set> | |
#include <memory> | |
#include <chrono> | |
#include <vector> | |
#include <algorithm> | |
#include <cmath> | |
#include <iostream> | |
#include <sparsehash/dense_hash_set> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void* Consume(size_t& size); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void* RequestNode(size_t sz); | |
void* EnqueueMore(size_t sz); | |
void CommitNode(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is an idealized pseudo-implementation. Details are omitted for clarity | |
SMDataQueueBase::SMDataQueueBase(bool initializeMemory) | |
{ | |
CreateSharedMemoryRegion(); | |
if(initializeMemory) | |
{ | |
new(m_SharedData) SharedData; | |
// Allocate an empty node | |
m_SharedData->m_Head = *AllocateNode(sizeof(size_t)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SMDataQueueBase::Node* SMDataQueueBase::AllocateFirstNodeOnPage(size_t size) | |
{ | |
if(m_FreePages.empty()) | |
{ | |
// garbage collect | |
m_UsedPages.erase(std::remove_if(m_UsedPages.begin(), m_UsedPages.end(), [this](unsigned pageId) -> bool | |
{ | |
const bool isFree = m_Pages[pageId]->NodesOwned == 0; | |
if (isFree) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
polymorphic MakeDepth | |
{ | |
CalculateProjectionDepth | |
} | |
polymorphic GetWorldNormal | |
{ | |
NormalFromInput, | |
NormalFromMap | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//texture inputs | |
Texture2D map_normal : register(t0); | |
SamplerState sampler_point : register(s0); | |
//sampler inputs | |
//input | |
struct PS_INPUT { | |
float4 Position : SV_POSITION; | |
float3 binormal : TEXCOORD0; | |
float3 normal_o : TEXCOORD1; | |
float3 normal_t : TEXCOORD2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
atom NORMAL_W NormalFromInput(interface context) needs NORMAL_O | |
{ | |
return mul(context.normal_o, World); | |
} | |
atom NORMAL_W NormalFromMap(interface context) needs NORMAL_O, UV, TBN, MAP_NORMAL, SAMPLER_POINT | |
{ | |
float3 normal = map_normal.Sample(sampler_point, context.uv); | |
normal = mul(normal, context.tbn); | |
normal = normalize(context.normal_o + normal); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void VOID : void; | |
float3x3 TBN : TEXCOORD; | |
float3 NORMAL_T : NORMAL; | |
float3 NORMAL_O : NORMAL; | |
float3 NORMAL_W : NORMAL; | |
float3 TANGENT : TANGENT; | |
float3 BINORMAL : BINORMAL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
concretizer TBN ComputeTBN(interface context) needs TANGENT, BINORMAL, NORMAL_T | |
{ | |
return float3x3(context.tangent, context.binormal, context.normal_t); | |
} |
OlderNewer