diff --git a/src/swrenderer/drawers/r_draw_rgba.cpp b/src/swrenderer/drawers/r_draw_rgba.cpp index a520d28ae..fcf94e5da 100644 --- a/src/swrenderer/drawers/r_draw_rgba.cpp +++ b/src/swrenderer/drawers/r_draw_rgba.cpp @@ -329,6 +329,7 @@ namespace swrenderer args.textureheight1 = dc_wall_sourceheight[1]; args.top_color = solid_top; args.bottom_color = solid_bottom; + args.flags = fadeSky ? DrawSkyArgs::fade_sky : 0; DetectRangeError(args.dest, args.dest_y, args.count); } diff --git a/src/swrenderer/drawers/r_drawers.h b/src/swrenderer/drawers/r_drawers.h index 0492930d9..2d251478c 100644 --- a/src/swrenderer/drawers/r_drawers.h +++ b/src/swrenderer/drawers/r_drawers.h @@ -200,6 +200,11 @@ struct DrawSkyArgs uint32_t textureheight1; uint32_t top_color; uint32_t bottom_color; + uint32_t flags; + enum Flags + { + fade_sky = 1 + }; FString ToString(); }; diff --git a/tools/drawergen/fixedfunction/drawskycodegen.cpp b/tools/drawergen/fixedfunction/drawskycodegen.cpp index 3bd23e529..9fdd33a17 100644 --- a/tools/drawergen/fixedfunction/drawskycodegen.cpp +++ b/tools/drawergen/fixedfunction/drawskycodegen.cpp @@ -47,12 +47,15 @@ void DrawSkyCodegen::Generate(DrawSkyVariant variant, SSAValue args, SSAValue th maxtextureheight1 = textureheight1 - 1; top_color = SSAVec4i::unpack(args[0][22].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.num_cores = thread_data[0][1].load(true); thread.pass_start_y = thread_data[0][2].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); 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)); 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)); { @@ -76,8 +84,15 @@ void DrawSkyCodegen::Loop(DrawSkyVariant variant) SSAInt offset = index * pitch * 4; - SSAVec4i color = FadeOut(frac, Sample(frac, variant)); - dest[offset].store_vec4ub(color); + if (fade_sky) + { + 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_frac.store(frac + fracstep); diff --git a/tools/drawergen/fixedfunction/drawskycodegen.h b/tools/drawergen/fixedfunction/drawskycodegen.h index 6cd700203..463c8ca23 100644 --- a/tools/drawergen/fixedfunction/drawskycodegen.h +++ b/tools/drawergen/fixedfunction/drawskycodegen.h @@ -36,7 +36,7 @@ public: void Generate(DrawSkyVariant variant, SSAValue args, SSAValue thread_data); private: - void Loop(DrawSkyVariant variant); + void Loop(DrawSkyVariant variant, bool fade_sky); SSAVec4i Sample(SSAInt frac, DrawSkyVariant variant); SSAVec4i FadeOut(SSAInt frac, SSAVec4i color); @@ -57,4 +57,6 @@ private: SSAWorkerThread thread; SSAInt fracstep; + + SSABool is_fade_sky; }; diff --git a/tools/drawergen/llvmdrawers.cpp b/tools/drawergen/llvmdrawers.cpp index 995b5b849..782259702 100644 --- a/tools/drawergen/llvmdrawers.cpp +++ b/tools/drawergen/llvmdrawers.cpp @@ -280,7 +280,7 @@ llvm::Type *LLVMDrawers::GetDrawSkyArgsStruct(llvm::LLVMContext &context) 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++) + for (int i = 0; i < 16; i++) elements.push_back(llvm::Type::getInt32Ty(context)); DrawSkyArgsStruct = llvm::StructType::create(context, elements, "DrawSkyArgs", false)->getPointerTo(); return DrawSkyArgsStruct;