Add support for repeating skies in the TC sky drawer

This commit is contained in:
Magnus Norddahl 2017-01-19 00:12:54 +01:00
parent 8788a9e788
commit 111b5c5469
5 changed files with 29 additions and 6 deletions

View file

@ -329,6 +329,7 @@ namespace swrenderer
args.textureheight1 = dc_wall_sourceheight[1]; args.textureheight1 = dc_wall_sourceheight[1];
args.top_color = solid_top; args.top_color = solid_top;
args.bottom_color = solid_bottom; args.bottom_color = solid_bottom;
args.flags = fadeSky ? DrawSkyArgs::fade_sky : 0;
DetectRangeError(args.dest, args.dest_y, args.count); DetectRangeError(args.dest, args.dest_y, args.count);
} }

View file

@ -200,6 +200,11 @@ struct DrawSkyArgs
uint32_t textureheight1; uint32_t textureheight1;
uint32_t top_color; uint32_t top_color;
uint32_t bottom_color; uint32_t bottom_color;
uint32_t flags;
enum Flags
{
fade_sky = 1
};
FString ToString(); FString ToString();
}; };

View file

@ -47,12 +47,15 @@ void DrawSkyCodegen::Generate(DrawSkyVariant variant, SSAValue args, SSAValue th
maxtextureheight1 = textureheight1 - 1; maxtextureheight1 = textureheight1 - 1;
top_color = SSAVec4i::unpack(args[0][22].load(true)); top_color = SSAVec4i::unpack(args[0][22].load(true));
bottom_color = SSAVec4i::unpack(args[0][23].load(true)); bottom_color = SSAVec4i::unpack(args[0][23].load(true));
SSAInt flags = args[0][24].load(true);
thread.core = thread_data[0][0].load(true); thread.core = thread_data[0][0].load(true);
thread.num_cores = thread_data[0][1].load(true); thread.num_cores = thread_data[0][1].load(true);
thread.pass_start_y = thread_data[0][2].load(true); thread.pass_start_y = thread_data[0][2].load(true);
thread.pass_end_y = thread_data[0][3].load(true); thread.pass_end_y = thread_data[0][3].load(true);
is_fade_sky = (flags & DrawSkyArgs::fade_sky) == SSAInt(DrawSkyArgs::fade_sky);
count = count_for_thread(dest_y, count, thread); count = count_for_thread(dest_y, count, thread);
dest = dest_for_thread(dest_y, pitch, dest, thread); dest = dest_for_thread(dest_y, pitch, dest, thread);
@ -61,10 +64,15 @@ void DrawSkyCodegen::Generate(DrawSkyVariant variant, SSAValue args, SSAValue th
stack_frac.store(texturefrac + iscale * skipped_by_thread(dest_y, thread)); stack_frac.store(texturefrac + iscale * skipped_by_thread(dest_y, thread));
fracstep = iscale * thread.num_cores; fracstep = iscale * thread.num_cores;
Loop(variant); SSAIfBlock branch;
branch.if_block(is_fade_sky);
Loop(variant, true);
branch.else_block();
Loop(variant, false);
branch.end_block();
} }
void DrawSkyCodegen::Loop(DrawSkyVariant variant) void DrawSkyCodegen::Loop(DrawSkyVariant variant, bool fade_sky)
{ {
stack_index.store(SSAInt(0)); stack_index.store(SSAInt(0));
{ {
@ -76,8 +84,15 @@ void DrawSkyCodegen::Loop(DrawSkyVariant variant)
SSAInt offset = index * pitch * 4; SSAInt offset = index * pitch * 4;
SSAVec4i color = FadeOut(frac, Sample(frac, variant)); if (fade_sky)
dest[offset].store_vec4ub(color); {
SSAVec4i color = FadeOut(frac, Sample(frac, variant));
dest[offset].store_vec4ub(color);
}
else
{
dest[offset].store_vec4ub(Sample(frac, variant));
}
stack_index.store(index.add(SSAInt(1), true, true)); stack_index.store(index.add(SSAInt(1), true, true));
stack_frac.store(frac + fracstep); stack_frac.store(frac + fracstep);

View file

@ -36,7 +36,7 @@ public:
void Generate(DrawSkyVariant variant, SSAValue args, SSAValue thread_data); void Generate(DrawSkyVariant variant, SSAValue args, SSAValue thread_data);
private: private:
void Loop(DrawSkyVariant variant); void Loop(DrawSkyVariant variant, bool fade_sky);
SSAVec4i Sample(SSAInt frac, DrawSkyVariant variant); SSAVec4i Sample(SSAInt frac, DrawSkyVariant variant);
SSAVec4i FadeOut(SSAInt frac, SSAVec4i color); SSAVec4i FadeOut(SSAInt frac, SSAVec4i color);
@ -57,4 +57,6 @@ private:
SSAWorkerThread thread; SSAWorkerThread thread;
SSAInt fracstep; SSAInt fracstep;
SSABool is_fade_sky;
}; };

View file

@ -280,7 +280,7 @@ llvm::Type *LLVMDrawers::GetDrawSkyArgsStruct(llvm::LLVMContext &context)
elements.push_back(llvm::Type::getInt8PtrTy(context)); elements.push_back(llvm::Type::getInt8PtrTy(context));
for (int i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
elements.push_back(llvm::Type::getInt8PtrTy(context)); elements.push_back(llvm::Type::getInt8PtrTy(context));
for (int i = 0; i < 15; i++) for (int i = 0; i < 16; i++)
elements.push_back(llvm::Type::getInt32Ty(context)); elements.push_back(llvm::Type::getInt32Ty(context));
DrawSkyArgsStruct = llvm::StructType::create(context, elements, "DrawSkyArgs", false)->getPointerTo(); DrawSkyArgsStruct = llvm::StructType::create(context, elements, "DrawSkyArgs", false)->getPointerTo();
return DrawSkyArgsStruct; return DrawSkyArgsStruct;