ID:1893380
 
Resolved
The method used to upscale maps in hardware mode has been altered to work around StretchRect() bugs in stupid stupid Nvidia drivers.
BYOND Version:508.1292
Operating System:Windows 7 Ultimate
Web Browser:Chrome 43.0.2357.130
Applies to:Dream Seeker
Status: Resolved (510.1342)

This issue has been resolved.
Descriptive Problem Summary:

The new map scaling algorithm is off by a little bit. Give Dawncaster a run in the latest version, and you'll notice the map is being blitted at 1,1 rather than 0,0 causing a bizarre wraparound of the bottom and right side of the texture onto the top and left side of the map.

This is causing any scaled map to be off by a single pixel.
I'm not seeing an offset, but I am seeing rendering problems (specifically on my system it outright fails to use DirectX) brought on by the large zoom, which I'm looking into.
I'll record a capture tonight and post my specs. I'm probably running the highest end pc in the community, so it's indicative of more than just bad configuration.
In response to Ter13
Ter13 wrote:
I'll record a capture tonight and post my specs. I'm probably running the highest end pc in the community, so it's indicative of more than just bad configuration.

Indeed. Your PC is probably actually using DirectX whereas mine is jumping out of it because of the high resolution (after zoom), but I think I can fix the hi-res issue. The drawing position really shouldn't be off by 1 though, and that has me really puzzled.
I was able to fix the issue that was pushing mine out of DirectX, although I did not see your issue in action. More info will be needed. I'll include my fix in 508.1293 anyway because I think it's beneficial across the board.
http://gfycat.com/ClosedThisBream

Watch the top and left side of the screen. You'll see bleed of effects from the bottom and right side of the screen.

This issue disappears when hardware mode is turned off. It reappears when it's turned back on.

As for my machine's specs, I'm running:

Windows 7 64 bit ultimate

Intel Core i7 920 @ 4.0ghz, hyperthreading off (2.667ghz stock)

6GB RAM installed ATM (had a couple sticks go bad, fell back to some old sticks recently)

Nvidia GTX960 SuperACX2.0 2GB GPU (http://www.geforce.com/hardware/desktop-gpus/ geforce-gtx-960/specifications) up to DX 12 API

Currently running DirectX 11.

Running display driver version: 9.18.13.5012

Anything else you'd like to know about my machine?
As far as I can tell this misalignment is an artifact of your video card. The coordinates to StretchRect() are correct:

DXSurface s;
src = CRect(CPoint(0,0), m_gWnd->m_truePixels);
CRect dest2(CPoint(0,0), m_surfaceDestSize);
HRESULT hr = m_d3dDevice->GetBackBuffer(0,0,D3DBACKBUFFER_TYPE_MONO,&s);
if(FAILED(hr)) {
m_errorString = "Unable to get backbuffer";
return GDRV_FAIL;
}
hr = m_d3dDevice->StretchRect(m_surface,src,s,dest2,D3DTEXF_POINT);

(BTW, the backbuffer is getting released later, no worries.) And then the Present() call after that looks fine.

m_d3dDevice->Present(psrc,dest,NULL,NULL);

The psrc value is NULL; the var only exists for some workaround code that isn't used.

Here's the kicker though: That dest rectangle comes from this:

CRect dest(m_gWnd->m_offPixels,m_gWnd->m_screenPixels);

m_screenPixels is basically zoom * m_truePixels, and since you're using 16x zoom and m_truePixels is in the 330x330 neighborhood, that's a very high number. m_offPixels is what you get by subtracting m_screenPixels from the actual map size and dividing by 2.

In the current code, m_offPixels is very negative in both dimensions, and m_screenPixels is a very high size--much bigger than the actual output window. So I believe that's happening is that while your video card is capable of rendering at that huge size, it's doing some kind of rounding and running into rounding error. My suspicion is that my fix for lesser systems, which constrains m_offPixels and m_screenPixels to smaller values by introducing an offset to the sprite drawing stage, will fix this completely.
With icon_size=16 and map.zoom=2,

The center row and column are duplicated:


So the south and east edge are cut off by one screen-pixel (half a map-pixel):



NVIDIA GeForce GTX 560 Ti.

(Also, the top pixel row and left-most visible pixel column catch mouse events without a screen-loc parameter, when moving from outside to in)
In response to Kaiochao
Related: http://www.byond.com/forum/?post=1893380

Something isn't right.

NVIDIA GeForce GTX 960.
In response to Kaiochao
I can confirm this.

Set DS to x2 icon size (64x64 with the default of 32x32 icons) and you will notice that pixels in the middle of the x and y axis are double thick.

I think I've had it happen on both a GTX 660 M and on a GTX 660 TI.
In response to Kaiochao
I can confirm this further. I just ran into this issue at x2 scale.
In response to Kaiochao
Do you have a demo on this? I suspect this same issue has another report but I have nothing to reproduce it with.
In response to Kaiochao


Can reproduce it on /vg/'s test server just fine: byond://ss13.loveisover.me:7777
In response to Kaiochao
As I said in the other thread, a simple demo I can run myself is best. I don't want to depend on an outside server if possible.
In response to Kaiochao
Here's all 11 lines of code.

http://files.byondhome.com/Ter13/ SmallestBugReportEver_src.zip

Bonus optical illusion because really?
In response to Kaiochao
I tried that demo but couldn't see the issue myself; however, my card is not an NVIDIA. I wonder if that's part of the issue here. Maybe that card frells up StretchRect() for some reason.
In response to Kaiochao
This sounds like the issue I reported a few years ago. Exact same symptoms.
In response to LordAndrew
That does look suspiciously similar. Do you also have an NVIDIA card?

I did a quick look a little while ago to see if I could find any info on this, but I came up empty. If any enterprising Google sleuths want to take up the challenge, maybe you can find something.

My ultimate hunch is that the NVIDIA cards are implementing StretchRect() by assigning the source image to a texture and then using that, but that they're not accounting for a rounding error in their texture sample positions and it's causing some grief. If that's the case it may or may not be solvable by abandoning StetchRect() in favor of the uglier texture approach.
In response to Lummox JR
I have an NVIDIA GeForce 6150SE nForce 430. A rather long name consider how rubbish it is.

The bizarre thing about this issue (and I mentioned it in my bug report): if you take a screenshot using BYOND's built-in screenshot function, the scaling fixes itself. Not sure why that'd be, but maybe a solution lies somewhere in that?
In response to Kaiochao
Does the scaling fix itself in the screenshot only, or also on the map? All the screenshot does is grab the back buffer--or in newer cases, the temporary surface used for rendering before StretchRect() is called--and output that data.
Page: 1 2