[2.1] dds is Compressed, run InstantRadiosity crash in D3D11

Discussion area about developing with Ogre-Next (2.1, 2.2 and beyond)


Post Reply
renyingzhi1006043
Gnoblar
Posts: 23
Joined: Wed May 03, 2017 4:12 am

[2.1] dds is Compressed, run InstantRadiosity crash in D3D11

Post by renyingzhi1006043 »

i found crash in OgreD3D11Mappings.cpp line 243

Code: Select all

        // The main issue - pitches D3D11 are in bytes, but Ogre stores them in elements, therefore conversion is required
        size_t elemSize = PixelUtil::getNumElemBytes(box.format);
        assert(0 == mapping.RowPitch % elemSize);
        assert(0 == mapping.DepthPitch % elemSize);

        box.data = mapping.pData;
        box.rowPitch = mapping.RowPitch / elemSize;
        box.slicePitch = mapping.DepthPitch / elemSize;
because elemSize =0.
i modifyed:

Code: Select all

	// The main issue - pitches D3D11 are in bytes, but Ogre stores them in elements, therefore conversion is required
	size_t elemSize = PixelUtil::getNumElemBytes(box.format);

	if (elemSize != 0)
	{
		box.rowPitch = mapping.RowPitch / elemSize;
		box.slicePitch = mapping.DepthPitch / elemSize;

		assert(0 == mapping.RowPitch % elemSize);
		assert(0 == mapping.DepthPitch % elemSize);
	}
	else if (PixelUtil::isCompressed(box.format))
	{
		box.rowPitch = box.getWidth();
		box.slicePitch = box.getWidth() * box.getHeight();
	}
	else
	{
		OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS,
			"Invalid pixel format", "setPixelBoxMapping");
	}
	box.data = mapping.pData;
but in InstantRadiosity hit.material.image getColourAt will crash.

need help

thanks!
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: [2.1] dds is Compressed, run InstantRadiosity crash in D

Post by dark_sylinc »

Grrr, yeah this is a bug / unimplemented feature; I didn't even realize.

We cannot just read BCn compression directly, it needs to be decompressed.

DDSCodec::decode knows how to decompress BC1-BC3 compression in software; but it's written to load a DDS file. Sadly at the moment I don't have the time to do it, but it could be moderately easy to write a routine that only converts a BC1/3 compressed pointer to a pointer in RGBA using the code from DDSCodec::decode as reference.
renyingzhi1006043
Gnoblar
Posts: 23
Joined: Wed May 03, 2017 4:12 am

Re: [2.1] dds is Compressed, run InstantRadiosity crash in D

Post by renyingzhi1006043 »

I felt really bad.
My old project use dxt1 and dxt5 dds in Ogre1.9, its run fine.
but now in 2.1 cannot Support.
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: [2.1] dds is Compressed, run InstantRadiosity crash in D

Post by dark_sylinc »

I'm sorry you feel that way.

We will eventually fix it, but I cannot promise it will be fixed quickly.

Please note that in Ogre 1.9 there was no InstantRadiosity feature to begin with.

I just added a workaround. If the texture is compressed, it won't be used, which prevents the crash. It will use the diffuse colour of the material instead.

It's not a perfect solution but at least it won't crash.

Cheers
Matias
renyingzhi1006043
Gnoblar
Posts: 23
Joined: Wed May 03, 2017 4:12 am

Re: [2.1] dds is Compressed, run InstantRadiosity crash in D

Post by renyingzhi1006043 »

thanks
Cheers!
Post Reply