2016-12-04 17:19:01 +00:00
|
|
|
/*
|
|
|
|
** LLVM code generated drawers
|
|
|
|
** Copyright (c) 2016 Magnus Norddahl
|
|
|
|
**
|
|
|
|
** This software is provided 'as-is', without any express or implied
|
|
|
|
** warranty. In no event will the authors be held liable for any damages
|
|
|
|
** arising from the use of this software.
|
|
|
|
**
|
|
|
|
** Permission is granted to anyone to use this software for any purpose,
|
|
|
|
** including commercial applications, and to alter it and redistribute it
|
|
|
|
** freely, subject to the following restrictions:
|
|
|
|
**
|
|
|
|
** 1. The origin of this software must not be misrepresented; you must not
|
|
|
|
** claim that you wrote the original software. If you use this software
|
|
|
|
** in a product, an acknowledgment in the product documentation would be
|
|
|
|
** appreciated but is not required.
|
|
|
|
** 2. Altered source versions must be plainly marked as such, and must not be
|
|
|
|
** misrepresented as being the original software.
|
|
|
|
** 3. This notice may not be removed or altered from any source distribution.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "precomp.h"
|
|
|
|
#include "timestamp.h"
|
|
|
|
#include "llvmdrawers.h"
|
|
|
|
#include "exception.h"
|
|
|
|
|
|
|
|
LLVMDrawers::LLVMDrawers(const std::string &triple, const std::string &cpuName, const std::string &features, const std::string namePostfix) : mNamePostfix(namePostfix)
|
|
|
|
{
|
|
|
|
mProgram.CreateModule();
|
|
|
|
|
2016-12-25 04:46:16 +00:00
|
|
|
CodegenDrawColumn("FillColumn", DrawColumnVariant::Fill);
|
|
|
|
CodegenDrawColumn("FillColumnAdd", DrawColumnVariant::FillAdd);
|
|
|
|
CodegenDrawColumn("FillColumnAddClamp", DrawColumnVariant::FillAddClamp);
|
|
|
|
CodegenDrawColumn("FillColumnSubClamp", DrawColumnVariant::FillSubClamp);
|
|
|
|
CodegenDrawColumn("FillColumnRevSubClamp", DrawColumnVariant::FillRevSubClamp);
|
|
|
|
CodegenDrawColumn("DrawColumn", DrawColumnVariant::Draw);
|
|
|
|
CodegenDrawColumn("DrawColumnAdd", DrawColumnVariant::DrawAdd);
|
|
|
|
CodegenDrawColumn("DrawColumnShaded", DrawColumnVariant::DrawShaded);
|
|
|
|
CodegenDrawColumn("DrawColumnAddClamp", DrawColumnVariant::DrawAddClamp);
|
|
|
|
CodegenDrawColumn("DrawColumnSubClamp", DrawColumnVariant::DrawSubClamp);
|
|
|
|
CodegenDrawColumn("DrawColumnRevSubClamp", DrawColumnVariant::DrawRevSubClamp);
|
|
|
|
CodegenDrawColumn("DrawColumnTranslated", DrawColumnVariant::DrawTranslated);
|
|
|
|
CodegenDrawColumn("DrawColumnTlatedAdd", DrawColumnVariant::DrawTlatedAdd);
|
|
|
|
CodegenDrawColumn("DrawColumnAddClampTranslated", DrawColumnVariant::DrawAddClampTranslated);
|
|
|
|
CodegenDrawColumn("DrawColumnSubClampTranslated", DrawColumnVariant::DrawSubClampTranslated);
|
|
|
|
CodegenDrawColumn("DrawColumnRevSubClampTranslated", DrawColumnVariant::DrawRevSubClampTranslated);
|
2016-12-04 17:19:01 +00:00
|
|
|
CodegenDrawSpan("DrawSpan", DrawSpanVariant::Opaque);
|
|
|
|
CodegenDrawSpan("DrawSpanMasked", DrawSpanVariant::Masked);
|
|
|
|
CodegenDrawSpan("DrawSpanTranslucent", DrawSpanVariant::Translucent);
|
|
|
|
CodegenDrawSpan("DrawSpanMaskedTranslucent", DrawSpanVariant::MaskedTranslucent);
|
|
|
|
CodegenDrawSpan("DrawSpanAddClamp", DrawSpanVariant::AddClamp);
|
|
|
|
CodegenDrawSpan("DrawSpanMaskedAddClamp", DrawSpanVariant::MaskedAddClamp);
|
2016-12-27 06:18:04 +00:00
|
|
|
CodegenDrawWall("vlinec1", DrawWallVariant::Opaque);
|
|
|
|
CodegenDrawWall("mvlinec1", DrawWallVariant::Masked);
|
|
|
|
CodegenDrawWall("tmvline1_add", DrawWallVariant::Add);
|
|
|
|
CodegenDrawWall("tmvline1_addclamp", DrawWallVariant::AddClamp);
|
|
|
|
CodegenDrawWall("tmvline1_subclamp", DrawWallVariant::SubClamp);
|
|
|
|
CodegenDrawWall("tmvline1_revsubclamp", DrawWallVariant::RevSubClamp);
|
|
|
|
CodegenDrawSky("DrawSky1", DrawSkyVariant::Single);
|
|
|
|
CodegenDrawSky("DrawDoubleSky1", DrawSkyVariant::Double);
|
2016-12-04 17:19:01 +00:00
|
|
|
for (int i = 0; i < NumTriBlendModes(); i++)
|
|
|
|
{
|
2016-12-15 22:29:31 +00:00
|
|
|
CodegenDrawTriangle("TriDraw8_" + std::to_string(i), (TriBlendMode)i, false, false);
|
|
|
|
CodegenDrawTriangle("TriDraw32_" + std::to_string(i), (TriBlendMode)i, true, false);
|
|
|
|
CodegenDrawTriangle("TriFill8_" + std::to_string(i), (TriBlendMode)i, false, true);
|
|
|
|
CodegenDrawTriangle("TriFill32_" + std::to_string(i), (TriBlendMode)i, true, true);
|
2016-12-04 17:19:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ObjectFile = mProgram.GenerateObjectFile(triple, cpuName, features);
|
|
|
|
}
|
|
|
|
|
2016-12-25 04:46:16 +00:00
|
|
|
void LLVMDrawers::CodegenDrawColumn(const char *name, DrawColumnVariant variant)
|
2016-12-04 17:19:01 +00:00
|
|
|
{
|
|
|
|
llvm::IRBuilder<> builder(mProgram.context());
|
|
|
|
SSAScope ssa_scope(&mProgram.context(), mProgram.module(), &builder);
|
|
|
|
|
|
|
|
SSAFunction function(name + mNamePostfix);
|
|
|
|
function.add_parameter(GetDrawColumnArgsStruct(mProgram.context()));
|
|
|
|
function.add_parameter(GetWorkerThreadDataStruct(mProgram.context()));
|
|
|
|
function.create_public();
|
|
|
|
|
|
|
|
DrawColumnCodegen codegen;
|
2016-12-25 04:46:16 +00:00
|
|
|
codegen.Generate(variant, function.parameter(0), function.parameter(1));
|
2016-12-04 17:19:01 +00:00
|
|
|
|
|
|
|
builder.CreateRetVoid();
|
|
|
|
|
|
|
|
if (llvm::verifyFunction(*function.func))
|
|
|
|
throw Exception("verifyFunction failed for CodegenDrawColumn()");
|
|
|
|
}
|
|
|
|
|
|
|
|
void LLVMDrawers::CodegenDrawSpan(const char *name, DrawSpanVariant variant)
|
|
|
|
{
|
|
|
|
llvm::IRBuilder<> builder(mProgram.context());
|
|
|
|
SSAScope ssa_scope(&mProgram.context(), mProgram.module(), &builder);
|
|
|
|
|
|
|
|
SSAFunction function(name + mNamePostfix);
|
|
|
|
function.add_parameter(GetDrawSpanArgsStruct(mProgram.context()));
|
|
|
|
function.create_public();
|
|
|
|
|
|
|
|
DrawSpanCodegen codegen;
|
|
|
|
codegen.Generate(variant, function.parameter(0));
|
|
|
|
|
|
|
|
builder.CreateRetVoid();
|
|
|
|
|
|
|
|
if (llvm::verifyFunction(*function.func))
|
|
|
|
throw Exception("verifyFunction failed for CodegenDrawSpan()");
|
|
|
|
}
|
|
|
|
|
2016-12-27 06:18:04 +00:00
|
|
|
void LLVMDrawers::CodegenDrawWall(const char *name, DrawWallVariant variant)
|
2016-12-04 17:19:01 +00:00
|
|
|
{
|
|
|
|
llvm::IRBuilder<> builder(mProgram.context());
|
|
|
|
SSAScope ssa_scope(&mProgram.context(), mProgram.module(), &builder);
|
|
|
|
|
|
|
|
SSAFunction function(name + mNamePostfix);
|
|
|
|
function.add_parameter(GetDrawWallArgsStruct(mProgram.context()));
|
|
|
|
function.add_parameter(GetWorkerThreadDataStruct(mProgram.context()));
|
|
|
|
function.create_public();
|
|
|
|
|
|
|
|
DrawWallCodegen codegen;
|
2016-12-27 06:18:04 +00:00
|
|
|
codegen.Generate(variant, function.parameter(0), function.parameter(1));
|
2016-12-04 17:19:01 +00:00
|
|
|
|
|
|
|
builder.CreateRetVoid();
|
|
|
|
|
|
|
|
if (llvm::verifyFunction(*function.func))
|
|
|
|
throw Exception("verifyFunction failed for CodegenDrawWall()");
|
|
|
|
}
|
|
|
|
|
2016-12-27 06:18:04 +00:00
|
|
|
void LLVMDrawers::CodegenDrawSky(const char *name, DrawSkyVariant variant)
|
2016-12-04 17:19:01 +00:00
|
|
|
{
|
|
|
|
llvm::IRBuilder<> builder(mProgram.context());
|
|
|
|
SSAScope ssa_scope(&mProgram.context(), mProgram.module(), &builder);
|
|
|
|
|
|
|
|
SSAFunction function(name + mNamePostfix);
|
|
|
|
function.add_parameter(GetDrawSkyArgsStruct(mProgram.context()));
|
|
|
|
function.add_parameter(GetWorkerThreadDataStruct(mProgram.context()));
|
|
|
|
function.create_public();
|
|
|
|
|
|
|
|
DrawSkyCodegen codegen;
|
2016-12-27 06:18:04 +00:00
|
|
|
codegen.Generate(variant, function.parameter(0), function.parameter(1));
|
2016-12-04 17:19:01 +00:00
|
|
|
|
|
|
|
builder.CreateRetVoid();
|
|
|
|
|
|
|
|
if (llvm::verifyFunction(*function.func))
|
|
|
|
throw Exception("verifyFunction failed for CodegenDrawSky()");
|
|
|
|
}
|
|
|
|
|
2016-12-15 22:29:31 +00:00
|
|
|
void LLVMDrawers::CodegenDrawTriangle(const std::string &name, TriBlendMode blendmode, bool truecolor, bool colorfill)
|
2016-12-04 17:19:01 +00:00
|
|
|
{
|
|
|
|
llvm::IRBuilder<> builder(mProgram.context());
|
|
|
|
SSAScope ssa_scope(&mProgram.context(), mProgram.module(), &builder);
|
|
|
|
|
|
|
|
SSAFunction function(name + mNamePostfix);
|
|
|
|
function.add_parameter(GetTriDrawTriangleArgs(mProgram.context()));
|
|
|
|
function.add_parameter(GetWorkerThreadDataStruct(mProgram.context()));
|
|
|
|
function.create_public();
|
|
|
|
|
|
|
|
DrawTriangleCodegen codegen;
|
2016-12-15 22:29:31 +00:00
|
|
|
codegen.Generate(blendmode, truecolor, colorfill, function.parameter(0), function.parameter(1));
|
2016-12-04 17:19:01 +00:00
|
|
|
|
|
|
|
builder.CreateRetVoid();
|
|
|
|
|
|
|
|
if (llvm::verifyFunction(*function.func))
|
2016-12-15 22:29:31 +00:00
|
|
|
throw Exception("verifyFunction failed for CodegenDrawTriangle()");
|
2016-12-04 17:19:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
llvm::Type *LLVMDrawers::GetDrawColumnArgsStruct(llvm::LLVMContext &context)
|
|
|
|
{
|
2016-12-15 00:33:26 +00:00
|
|
|
if (DrawColumnArgsStruct)
|
|
|
|
return DrawColumnArgsStruct;
|
|
|
|
|
2016-12-04 17:19:01 +00:00
|
|
|
std::vector<llvm::Type *> elements;
|
|
|
|
elements.push_back(llvm::Type::getInt8PtrTy(context)); // uint32_t *dest;
|
|
|
|
elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint32_t *source;
|
|
|
|
elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint32_t *source2;
|
|
|
|
elements.push_back(llvm::Type::getInt8PtrTy(context)); // uint8_t *colormap;
|
|
|
|
elements.push_back(llvm::Type::getInt8PtrTy(context)); // uint8_t *translation;
|
|
|
|
elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint32_t *basecolors;
|
|
|
|
elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t pitch;
|
|
|
|
elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t count;
|
|
|
|
elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t dest_y;
|
|
|
|
elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t iscale;
|
|
|
|
elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t texturefracx;
|
|
|
|
elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t textureheight;
|
|
|
|
elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t texturefrac;
|
|
|
|
elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t light;
|
|
|
|
elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t color;
|
|
|
|
elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t srccolor;
|
|
|
|
elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t srcalpha;
|
|
|
|
elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t destalpha;
|
|
|
|
elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_alpha;
|
|
|
|
elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_red;
|
|
|
|
elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_green;
|
|
|
|
elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_blue;
|
|
|
|
elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_alpha;
|
|
|
|
elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_red;
|
|
|
|
elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_green;
|
|
|
|
elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_blue;
|
|
|
|
elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t desaturate;
|
|
|
|
elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t flags;
|
2016-12-15 00:33:26 +00:00
|
|
|
DrawColumnArgsStruct = llvm::StructType::create(context, elements, "DrawColumnArgs", false)->getPointerTo();
|
|
|
|
return DrawColumnArgsStruct;
|
2016-12-04 17:19:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
llvm::Type *LLVMDrawers::GetDrawSpanArgsStruct(llvm::LLVMContext &context)
|
|
|
|
{
|
2016-12-15 00:33:26 +00:00
|
|
|
if (DrawSpanArgsStruct)
|
|
|
|
return DrawSpanArgsStruct;
|
|
|
|
|
2016-12-04 17:19:01 +00:00
|
|
|
std::vector<llvm::Type *> elements;
|
|
|
|
elements.push_back(llvm::Type::getInt8PtrTy(context)); // uint8_t *destorg;
|
|
|
|
elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint32_t *source;
|
|
|
|
elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t destpitch;
|
|
|
|
elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t xfrac;
|
|
|
|
elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t yfrac;
|
|
|
|
elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t xstep;
|
|
|
|
elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t ystep;
|
|
|
|
elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t x1;
|
|
|
|
elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t x2;
|
|
|
|
elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t y;
|
|
|
|
elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t xbits;
|
|
|
|
elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t ybits;
|
|
|
|
elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t light;
|
|
|
|
elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t srcalpha;
|
|
|
|
elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t destalpha;
|
|
|
|
elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_alpha;
|
|
|
|
elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_red;
|
|
|
|
elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_green;
|
|
|
|
elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_blue;
|
|
|
|
elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_alpha;
|
|
|
|
elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_red;
|
|
|
|
elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_green;
|
|
|
|
elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_blue;
|
|
|
|
elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t desaturate;
|
|
|
|
elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t flags;
|
2016-12-22 07:42:21 +00:00
|
|
|
elements.push_back(llvm::Type::getFloatTy(context)); // float viewpos_x;
|
|
|
|
elements.push_back(llvm::Type::getFloatTy(context)); // float step_viewpos_x;
|
|
|
|
elements.push_back(GetTriLightStruct(context)); // TriLight *dynlights;
|
|
|
|
elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t num_dynlights;
|
2016-12-15 00:33:26 +00:00
|
|
|
DrawSpanArgsStruct = llvm::StructType::create(context, elements, "DrawSpanArgs", false)->getPointerTo();
|
|
|
|
return DrawSpanArgsStruct;
|
2016-12-04 17:19:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
llvm::Type *LLVMDrawers::GetDrawWallArgsStruct(llvm::LLVMContext &context)
|
|
|
|
{
|
2016-12-15 00:33:26 +00:00
|
|
|
if (DrawWallArgsStruct)
|
|
|
|
return DrawWallArgsStruct;
|
|
|
|
|
2016-12-04 17:19:01 +00:00
|
|
|
std::vector<llvm::Type *> elements;
|
|
|
|
elements.push_back(llvm::Type::getInt8PtrTy(context));
|
|
|
|
for (int i = 0; i < 8; i++)
|
|
|
|
elements.push_back(llvm::Type::getInt8PtrTy(context));
|
|
|
|
for (int i = 0; i < 25; i++)
|
|
|
|
elements.push_back(llvm::Type::getInt32Ty(context));
|
|
|
|
elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_alpha;
|
|
|
|
elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_red;
|
|
|
|
elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_green;
|
|
|
|
elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_blue;
|
|
|
|
elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_alpha;
|
|
|
|
elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_red;
|
|
|
|
elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_green;
|
|
|
|
elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_blue;
|
|
|
|
elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t desaturate;
|
|
|
|
elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t flags;
|
2016-12-20 22:21:34 +00:00
|
|
|
elements.push_back(llvm::Type::getFloatTy(context)); // float z;
|
|
|
|
elements.push_back(llvm::Type::getFloatTy(context)); // float step_z;
|
|
|
|
elements.push_back(GetTriLightStruct(context)); // TriLight *dynlights;
|
|
|
|
elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t num_dynlights;
|
|
|
|
|
2016-12-15 00:33:26 +00:00
|
|
|
DrawWallArgsStruct = llvm::StructType::create(context, elements, "DrawWallArgs", false)->getPointerTo();
|
|
|
|
return DrawWallArgsStruct;
|
2016-12-04 17:19:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
llvm::Type *LLVMDrawers::GetDrawSkyArgsStruct(llvm::LLVMContext &context)
|
|
|
|
{
|
2016-12-15 00:33:26 +00:00
|
|
|
if (DrawSkyArgsStruct)
|
|
|
|
return DrawSkyArgsStruct;
|
|
|
|
|
2016-12-04 17:19:01 +00:00
|
|
|
std::vector<llvm::Type *> elements;
|
|
|
|
elements.push_back(llvm::Type::getInt8PtrTy(context));
|
|
|
|
for (int i = 0; i < 8; i++)
|
|
|
|
elements.push_back(llvm::Type::getInt8PtrTy(context));
|
|
|
|
for (int i = 0; i < 15; i++)
|
|
|
|
elements.push_back(llvm::Type::getInt32Ty(context));
|
2016-12-15 00:33:26 +00:00
|
|
|
DrawSkyArgsStruct = llvm::StructType::create(context, elements, "DrawSkyArgs", false)->getPointerTo();
|
|
|
|
return DrawSkyArgsStruct;
|
2016-12-04 17:19:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
llvm::Type *LLVMDrawers::GetWorkerThreadDataStruct(llvm::LLVMContext &context)
|
|
|
|
{
|
2016-12-15 00:33:26 +00:00
|
|
|
if (WorkerThreadDataStruct)
|
|
|
|
return WorkerThreadDataStruct;
|
|
|
|
|
2016-12-04 17:19:01 +00:00
|
|
|
std::vector<llvm::Type *> elements;
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
elements.push_back(llvm::Type::getInt32Ty(context));
|
|
|
|
elements.push_back(llvm::Type::getInt8PtrTy(context));
|
2016-12-15 00:33:26 +00:00
|
|
|
elements.push_back(GetTriFullSpanStruct(context));
|
|
|
|
elements.push_back(GetTriPartialBlockStruct(context));
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
elements.push_back(llvm::Type::getInt32Ty(context));
|
|
|
|
WorkerThreadDataStruct = llvm::StructType::create(context, elements, "ThreadData", false)->getPointerTo();
|
|
|
|
return WorkerThreadDataStruct;
|
2016-12-04 17:19:01 +00:00
|
|
|
}
|
|
|
|
|
2016-12-20 22:21:34 +00:00
|
|
|
llvm::Type *LLVMDrawers::GetTriLightStruct(llvm::LLVMContext &context)
|
|
|
|
{
|
|
|
|
if (TriLightStruct)
|
|
|
|
return TriLightStruct;
|
|
|
|
|
|
|
|
std::vector<llvm::Type *> elements;
|
|
|
|
elements.push_back(llvm::Type::getInt32Ty(context));
|
2016-12-21 17:48:26 +00:00
|
|
|
for (int i = 0; i < 4; i++)
|
2016-12-20 22:21:34 +00:00
|
|
|
elements.push_back(llvm::Type::getFloatTy(context));
|
|
|
|
TriLightStruct = llvm::StructType::create(context, elements, "TriLight", false)->getPointerTo();
|
|
|
|
return TriLightStruct;
|
|
|
|
}
|
|
|
|
|
2016-12-04 17:19:01 +00:00
|
|
|
llvm::Type *LLVMDrawers::GetTriVertexStruct(llvm::LLVMContext &context)
|
|
|
|
{
|
2016-12-15 00:33:26 +00:00
|
|
|
if (TriVertexStruct)
|
|
|
|
return TriVertexStruct;
|
|
|
|
|
2016-12-04 17:19:01 +00:00
|
|
|
std::vector<llvm::Type *> elements;
|
|
|
|
for (int i = 0; i < 4 + TriVertex::NumVarying; i++)
|
|
|
|
elements.push_back(llvm::Type::getFloatTy(context));
|
2016-12-15 00:33:26 +00:00
|
|
|
TriVertexStruct = llvm::StructType::create(context, elements, "TriVertex", false)->getPointerTo();
|
|
|
|
return TriVertexStruct;
|
2016-12-04 17:19:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
llvm::Type *LLVMDrawers::GetTriMatrixStruct(llvm::LLVMContext &context)
|
|
|
|
{
|
2016-12-15 00:33:26 +00:00
|
|
|
if (TriMatrixStruct)
|
|
|
|
return TriMatrixStruct;
|
|
|
|
|
2016-12-04 17:19:01 +00:00
|
|
|
std::vector<llvm::Type *> elements;
|
|
|
|
for (int i = 0; i < 4 * 4; i++)
|
|
|
|
elements.push_back(llvm::Type::getFloatTy(context));
|
2016-12-15 00:33:26 +00:00
|
|
|
TriMatrixStruct = llvm::StructType::create(context, elements, "TriMatrix", false)->getPointerTo();
|
|
|
|
return TriMatrixStruct;
|
2016-12-04 17:19:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
llvm::Type *LLVMDrawers::GetTriUniformsStruct(llvm::LLVMContext &context)
|
|
|
|
{
|
2016-12-15 00:33:26 +00:00
|
|
|
if (TriUniformsStruct)
|
|
|
|
return TriUniformsStruct;
|
|
|
|
|
2016-12-04 17:19:01 +00:00
|
|
|
std::vector<llvm::Type *> elements;
|
|
|
|
elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t light;
|
|
|
|
elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t subsectorDepth;
|
|
|
|
elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t color;
|
|
|
|
elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t srcalpha;
|
|
|
|
elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t destalpha;
|
|
|
|
elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_alpha;
|
|
|
|
elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_red;
|
|
|
|
elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_green;
|
|
|
|
elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t light_blue;
|
|
|
|
elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_alpha;
|
|
|
|
elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_red;
|
|
|
|
elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_green;
|
|
|
|
elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_blue;
|
|
|
|
elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t desaturate;
|
|
|
|
elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t flags;
|
|
|
|
elements.push_back(GetTriMatrixStruct(context)); // TriMatrix objectToClip
|
2016-12-15 00:33:26 +00:00
|
|
|
TriUniformsStruct = llvm::StructType::create(context, elements, "TriUniforms", false)->getPointerTo();
|
|
|
|
return TriUniformsStruct;
|
|
|
|
}
|
|
|
|
|
|
|
|
llvm::Type *LLVMDrawers::GetTriFullSpanStruct(llvm::LLVMContext &context)
|
|
|
|
{
|
|
|
|
if (TriFullSpanStruct)
|
|
|
|
return TriFullSpanStruct;
|
|
|
|
|
|
|
|
std::vector<llvm::Type *> elements;
|
|
|
|
elements.push_back(llvm::Type::getInt16Ty(context)); // uint32_t X;
|
|
|
|
elements.push_back(llvm::Type::getInt16Ty(context)); // uint32_t Y;
|
|
|
|
elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t Length;
|
|
|
|
TriFullSpanStruct = llvm::StructType::create(context, elements, "TriFullSpan", false)->getPointerTo();
|
|
|
|
return TriFullSpanStruct;
|
|
|
|
}
|
|
|
|
|
|
|
|
llvm::Type *LLVMDrawers::GetTriPartialBlockStruct(llvm::LLVMContext &context)
|
|
|
|
{
|
|
|
|
if (TriPartialBlockStruct)
|
|
|
|
return TriPartialBlockStruct;
|
|
|
|
|
|
|
|
std::vector<llvm::Type *> elements;
|
|
|
|
elements.push_back(llvm::Type::getInt16Ty(context)); // uint32_t X;
|
|
|
|
elements.push_back(llvm::Type::getInt16Ty(context)); // uint32_t Y;
|
|
|
|
elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t Mask0;
|
|
|
|
elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t Mask1;
|
|
|
|
TriPartialBlockStruct = llvm::StructType::create(context, elements, "TriPartialBlock", false)->getPointerTo();
|
|
|
|
return TriPartialBlockStruct;
|
2016-12-04 17:19:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
llvm::Type *LLVMDrawers::GetTriDrawTriangleArgs(llvm::LLVMContext &context)
|
|
|
|
{
|
2016-12-15 00:33:26 +00:00
|
|
|
if (TriDrawTriangleArgs)
|
|
|
|
return TriDrawTriangleArgs;
|
|
|
|
|
2016-12-04 17:19:01 +00:00
|
|
|
std::vector<llvm::Type *> elements;
|
|
|
|
elements.push_back(llvm::Type::getInt8PtrTy(context)); // uint8_t *dest;
|
|
|
|
elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t pitch;
|
|
|
|
elements.push_back(GetTriVertexStruct(context)); // TriVertex *v1;
|
|
|
|
elements.push_back(GetTriVertexStruct(context)); // TriVertex *v2;
|
|
|
|
elements.push_back(GetTriVertexStruct(context)); // TriVertex *v3;
|
|
|
|
elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t clipleft;
|
|
|
|
elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t clipright;
|
|
|
|
elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t cliptop;
|
|
|
|
elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t clipbottom;
|
|
|
|
elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint8_t *texturePixels;
|
|
|
|
elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t textureWidth;
|
|
|
|
elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t textureHeight;
|
|
|
|
elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint8_t *translation;
|
|
|
|
elements.push_back(GetTriUniformsStruct(context)); // const TriUniforms *uniforms;
|
|
|
|
elements.push_back(llvm::Type::getInt8PtrTy(context)); // uint8_t *stencilValues;
|
|
|
|
elements.push_back(llvm::Type::getInt32PtrTy(context)); // uint32_t *stencilMasks;
|
|
|
|
elements.push_back(llvm::Type::getInt32Ty(context)); // int32_t stencilPitch;
|
|
|
|
elements.push_back(llvm::Type::getInt8Ty(context)); // uint8_t stencilTestValue;
|
|
|
|
elements.push_back(llvm::Type::getInt8Ty(context)); // uint8_t stencilWriteValue;
|
|
|
|
elements.push_back(llvm::Type::getInt32PtrTy(context)); // uint32_t *subsectorGBuffer;
|
|
|
|
elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint8_t *colormaps;
|
2016-12-19 16:27:46 +00:00
|
|
|
elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint8_t *RGB256k;
|
2016-12-04 17:19:01 +00:00
|
|
|
elements.push_back(llvm::Type::getInt8PtrTy(context)); // const uint8_t *BaseColors;
|
2016-12-15 00:33:26 +00:00
|
|
|
TriDrawTriangleArgs = llvm::StructType::create(context, elements, "TriDrawTriangle", false)->getPointerTo();
|
|
|
|
return TriDrawTriangleArgs;
|
2016-12-04 17:19:01 +00:00
|
|
|
}
|