diff --git a/engine/d3d/d3d11_image.c b/engine/d3d/d3d11_image.c index e93909d62..a5edd18b4 100644 --- a/engine/d3d/d3d11_image.c +++ b/engine/d3d/d3d11_image.c @@ -393,14 +393,14 @@ void D3D11_UploadLightmap(lightmapinfo_t *lm) mips.mip[0].width = lm->width; mips.mip[0].height = lm->height; mips.mip[0].datasize = lm->width*lm->height*4; - switch (lightmap_fmt) + switch (lm->fmt) { default: case PTI_A2BGR10: case PTI_E5BGR9: case PTI_RGBA16F: case PTI_RGBA32F: - mips.encoding = lightmap_fmt; + mips.encoding = lm->fmt; break; case PTI_BGRA8: mips.encoding = PTI_BGRX8; diff --git a/engine/d3d/d3d_backend.c b/engine/d3d/d3d_backend.c index 5da6d555b..9156cef8f 100644 --- a/engine/d3d/d3d_backend.c +++ b/engine/d3d/d3d_backend.c @@ -3292,13 +3292,14 @@ static void BE_UploadLightmaps(qboolean force) glRect_t *theRect = &lm->rectchange; int r; int w; + int pixbytes; if (!TEXLOADED(lm->lightmap_texture)) lm->lightmap_texture = Image_CreateTexture("***lightmap***", NULL, (r_lightmap_nearest.ival?IF_NEAREST:IF_LINEAR)|IF_NOMIPMAP); tex = lm->lightmap_texture->ptr; if (!tex) { - switch(lightmap_fmt) + switch(lm->fmt) { default: break; @@ -3342,10 +3343,11 @@ static void BE_UploadLightmaps(qboolean force) rect.top = theRect->t; rect.bottom = theRect->b; + pixbytes = lightmap[i]->pixbytes; IDirect3DTexture9_LockRect(tex, 0, &lock, &rect, 0); for (r = 0, w = theRect->r-theRect->l; r < lightmap[i]->rectchange.b-lightmap[i]->rectchange.t; r++) { - memcpy((char*)lock.pBits + r*lock.Pitch, lightmap[i]->lightmaps+(theRect->l+((r+theRect->t)*lm->width))*lightmap_bytes, w*lightmap_bytes); + memcpy((char*)lock.pBits + r*lock.Pitch, lightmap[i]->lightmaps+(theRect->l+((r+theRect->t)*lm->width))*pixbytes, w*pixbytes); } IDirect3DTexture9_UnlockRect(tex, 0); theRect->l = lm->width;