Skip to content

Instantly share code, notes, and snippets.

/**
* FiberTaskingLib - A tasking library that uses fibers for efficient task switching
*
* This library was created as a proof of concept of the ideas presented by
* Christian Gyrling in his 2015 GDC Talk 'Parallelizing the Naughty Dog Engine Using Fibers'
*
* http://gdcvault.com/play/1022186/Parallelizing-the-Naughty-Dog-Engine
*
* FiberTaskingLib is the legal property of Adrian Astley
* Copyright Adrian Astley 2015 - 2018
void Consumer(FiberTaskingLib::TaskScheduler *taskScheduler, void *arg) {
// No-Op
}
void Producer(FiberTaskingLib::TaskScheduler *taskScheduler, void *arg) {
FiberTaskingLib::Task *tasks = new FiberTaskingLib::Task[kNumConsumerTasks];
for (uint i = 0; i < kNumConsumerTasks; ++i) {
tasks[i] = { Consumer, arg };
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@RichieSams
RichieSams / managed_surface.cpp
Last active February 1, 2016 18:09
Support 16 and 32 bits per pixel
template<typename T>
void transBlitFrom(const Surface &src, const Common::Rect &srcRect, const Surface *dest, const Common::Rect &destRect, uint transColor, bool flipped, uint overrideColor) {
int scaleX = SCALE_THRESHOLD * srcRect.width() / destRect.width();
int scaleY = SCALE_THRESHOLD * srcRect.height() / destRect.height();
// Loop through drawing output lines
for (int destY = destRect.top, scaleYCtr = 0; destY < destRect.bottom; ++destY, scaleYCtr += scaleY) {
if (destY < 0 || destY >= dest->h)
continue;
const T *srcLine = (const T *)src.getBasePtr(0, scaleYCtr / SCALE_THRESHOLD);
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@RichieSams
RichieSams / example_solution.json
Created November 29, 2014 04:30
An example solution file for VisualProjectGen
{
"SolutionName": "MyApp",
"Projects": [
{
"ProjectName": "ProjectAwesomeSauce",
"ConfigurationDefinitions": [
{
"Configuration": "Debug",
"Platform": "Win32",
@RichieSams
RichieSams / foo
Created November 7, 2014 21:53
Question about using physically based light units
My question is:
How do you convert a light color and luminous power in the editor into a single color for use in the shader.
Let me explain. In listing 4 of the course notes from 'Moving Frostbite to PBR', you show some sample code. The last line is:
float3 luminance = BSDF(...) * saturate(dot(N, L)) * lightColor * att;
What does 'lightColor' represent? Is it the color of the light multiplied with its luminous intensity? AKA:
Point light: lightColor = <RGB color specified in editor> * lumPower / 4 / PI;
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
@RichieSams
RichieSams / gist:11164144
Last active August 29, 2015 14:00
The Halfling Project dot product problems
// In my shader code I retrieve a normal from spherical coordinates.
// The normal *should* be (0.0f, 0.0f, 1.0f), but due to some encoding errors
// it's a little bit off. I'm ok with that. However, when the value is used as
// is, it causes odd errors with the dot product or normalization.
// Here is an example. normal is calculated as above. lightVector comes in as
// a cbuffer variable. I've used shader debugging to verify the values of each.
// If I dot them directly, I get zero, when the product should be about 0.56
float3 normal = float3(0.0f, 0.0f, 0.9999900f);