mirror of
https://github.com/NoelFB/blah.git
synced 2025-06-29 19:25:26 +08:00
cleaning up D3D11 implementation
This commit is contained in:
@ -29,7 +29,6 @@ namespace Blah
|
||||
None = 0,
|
||||
Front = 1,
|
||||
Back = 2,
|
||||
Both = 3
|
||||
};
|
||||
|
||||
struct RenderPass
|
||||
|
@ -5,5 +5,31 @@ using namespace Blah;
|
||||
|
||||
ShaderRef Shader::create(const ShaderData* data)
|
||||
{
|
||||
return GraphicsBackend::create_shader(data);
|
||||
// get the shader
|
||||
auto shader = GraphicsBackend::create_shader(data);
|
||||
|
||||
// validate the shader
|
||||
if (shader)
|
||||
{
|
||||
auto& uniforms = shader->uniforms();
|
||||
|
||||
// make sure its uniforms are valid
|
||||
for (auto& it : uniforms)
|
||||
if (it.type == UniformType::None)
|
||||
{
|
||||
BLAH_ERROR_FMT("Uniform '%s' has an invalid type!\n\tOnly Float/Float2/Float3/Float4/Mat3x2/Mat4x4/Texture are allowed!", it.name.cstr());
|
||||
return ShaderRef();
|
||||
}
|
||||
|
||||
// make sure uniform names don't overlap
|
||||
for (int i = 0; i < uniforms.size(); i ++)
|
||||
for (int j = i + 1; j < uniforms.size(); j ++)
|
||||
if (uniforms[i].name == uniforms[j].name)
|
||||
{
|
||||
BLAH_ERROR_FMT("Shader Uniform names '%s' overlap! All Names must be unique.", uniforms[0].name.cstr());
|
||||
return ShaderRef();
|
||||
}
|
||||
}
|
||||
|
||||
return shader;
|
||||
}
|
@ -59,10 +59,10 @@ namespace Blah
|
||||
};
|
||||
|
||||
// Vertex Shader Program data
|
||||
const char* vertex;
|
||||
String vertex;
|
||||
|
||||
// Fragment Shader Program data
|
||||
const char* fragment;
|
||||
String fragment;
|
||||
|
||||
// HLSL Attributes - required for D3D11
|
||||
StackVector<HLSL_Attribute, 16> hlsl_attributes;
|
||||
|
@ -7,6 +7,9 @@
|
||||
#define BLAH_ERROR(message) \
|
||||
do { Log::error(message "\n\tin file: %s:%d", __FILE__, __LINE__); abort(); } while(0)
|
||||
|
||||
#define BLAH_ERROR_FMT(message, ...) \
|
||||
do { Log::error(message "\n\tin file: %s:%d", __VA_ARGS__, __FILE__, __LINE__); abort(); } while(0)
|
||||
|
||||
#define BLAH_ASSERT(condition, message) \
|
||||
do { if (!(condition)) { BLAH_ERROR(message); } } while(0)
|
||||
|
||||
@ -15,6 +18,9 @@
|
||||
#define BLAH_ERROR(message) \
|
||||
Log::error(message "\n\tin file: %s:%d", __FILE__, __LINE__)
|
||||
|
||||
#define BLAH_ERROR_FMT(message, ...) \
|
||||
Log::error(message "\n\tin file: %s:%d", __VA_ARGS__, __FILE__, __LINE__)
|
||||
|
||||
#define BLAH_ASSERT(condition, message) \
|
||||
do { } while(false)
|
||||
|
||||
|
Reference in New Issue
Block a user